Dataflows, Hidden Gem for Power Automate
Tags: powerautomate, powerplatform, powerbi, rpa
Published: 2023-01-12 09:37:05

Dealing with data in Power Automate simply isn't as easy as it should be. You are left to deal with data about looping over it, which is not only clunky but can burn through Power Platform API calls, leaving you and your flows throttled.

There is Office Scripts, which can be incredibly powerful (they are one of my favourite Power Automate features, if you want to know more check out my blog [here](https://dev.to/wyattdave/how-to-master-power-automate-scripts-4o8j)), yet they have their own drawbacks:

- Require developer to know TypeScript and Office Script language
- Has to be managed outside of the Platform
- Not built for ALM (moving between accounts is a nightmare)

But there is a hidden gem that fixes all your data problems, Dataflows. What's surprising is not many developers know about them or use them.

Dataflows are Power Query in Power Automate. Just like how you can transform your data when importing into Power BI, Dataflows are the same. So what's great is:

- Anyone with Power BI/Power Query can pick it up
- Its internal to platform
- Works with ALM

---


## Create a Simple Dataflow

Strangely Dataflows aren't made in Power Automate, but Power Apps, under the Dataverse options.

The Dataflow has to be built first, before it can be called in a flow (like an AI builder model).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0u0syu9yst4vxj9a4da2.png)

As said, it's just Power Query, so anyone with Power BI experience will pick it up straight away.

On a new Dataflow first select your data source, it can be pretty much any data connection, in this demo Im going to use a text/csv file (a notoriously difficult file to deal with in Power Automate) hosted in SharePoint.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvjvbvmnttdngv2hoxww.png)

I want to do the following data transformation

- Remove top row
- Remove Columns
- Reorder Columns
- Set Column type
- Add Calculated Column
- Filter Data
- Sort Data

All of this is easy in a Dataflow.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c4q1h6oe065fx82chf2d.png)

Becomes:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/aqjjtu7wukd0ude1dz9u.png)

You just step through all the changes you want and they are recorded in the 'Applied Steps' list in bottom right corner. Here they can also be edited and rearranged (I'm not going into detail how to do these steps, but it's very easy to pick up and there are links at the end of the blog).

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8zjymiisnwc572lgucqd.png)

The next step is where to store the transformed data, this needs to be a custom Dataverse Table.

The fields need to be mapped to the table field, and the Dataflow can be setup to either append to the table or overwrite all data.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xgeaf7w8x3693iq8200c.png)

## Run In a Flow

To run the Dataflow in a flow just use the Dataflow `Refresh a dataflow` action. The Dataflow is linked to the file/data, so the flow owner doesn't need access to the data, just the Dataflow.

Below Im going to just save it as a new csv, but you can do anything you can with data in Power Automate.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lu40e457pahpgl7li4ig.png)

Then you either set up another flow (recommended) or set long delay (not recommended), to download the Dataverse table.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4w4tf50womayttmvphdr.png)

The `When a dataflow refresh completes` trigger is ideal as will trigger on every Dataflow refresh.

And that's it, easy to set up, and easy to maintain. And there is so much more you can do, Pivot/UnPivot data, find and replace, the list goes on and on (just think how powerful Power BI is with data). Dataflows really should get more coverage because they are so useful.

---

**Further Reading**

- [learn.microsoft.com-create-and-use-dataflows](https://learn.microsoft.com/en-us/power-apps/maker/data-platform/create-and-use-dataflows)
- [learn.microsoft.com-/power-query-ui](https://learn.microsoft.com/en-us/power-query/power-query-ui)