Forum Discussion
Iterate through query results to page through results BUT using Power Automate?
I have this very odd situation where I need to use Power Automate to run a DAX query.
They have a connector for that and that works fine, but what I need to do for the next step is iterate through each row of the query results and run a loop that takes each row as a query filter.
It will run the query and build a CSV file to export.
I can't find any way to loop through query results in Power Automate from a DAX query.
I was hoping someone here has used Power Automate with PBI and Power Query as part of one of their workflows and can provide adive on how to loop through query results and execute a second query inside the loop.
I need to "page through" the results to compile them into a CSV.
To loop through DAX query results in Power Automate and process each row (for example, to filter further or create a CSV), use the "Run a query against a dataset" action, then apply a "Parse JSON" step to process the output array. After parsing, add an "Apply to Each" loop to iterate over each row, allowing you to dynamically use fields as query filters or compile the output step-by-step.
Inside the loop, for each row:
Run the next DAX query or custom action using row data as a filter parameter.
Append to a CSV using the "Append to String Variable" or build an array for export.
If you need to handle paging (for large result sets), limit your results via DAX using TOPN() or use offset/pagination mechanisms if supported by your API/data source.
This method covers how to loop through query results and export them efficiently with pure Power Automate , no code required beyond basic configuration
4 Replies
- Shubham_rai955
Super User
To loop through DAX query results in Power Automate and process each row (for example, to filter further or create a CSV), use the "Run a query against a dataset" action, then apply a "Parse JSON" step to process the output array. After parsing, add an "Apply to Each" loop to iterate over each row, allowing you to dynamically use fields as query filters or compile the output step-by-step.
Inside the loop, for each row:
Run the next DAX query or custom action using row data as a filter parameter.
Append to a CSV using the "Append to String Variable" or build an array for export.
If you need to handle paging (for large result sets), limit your results via DAX using TOPN() or use offset/pagination mechanisms if supported by your API/data source.
This method covers how to loop through query results and export them efficiently with pure Power Automate , no code required beyond basic configuration
- PhilipTreacy
Super User
Hi sasdfasdfsad
This is unclear what you are trying to do and why you are trying to do it.
Perhaps if you clearly explain what you are trying to do, and provide some sample data and an example of your desired result, it'll be much easier to help.
Why do you need to use PA to run a DAX query?
Can't you use Power Query to get the data you need for this CSV?
Can't you run the DAX and then export the data?
Phil
- v-echaithra
Community Support
Hi sasdfasdfsad ,
Thank you Shubham_rai955 , PhilipTreacy for your inputs.
Just following up to see if the Response provided by community members were helpful in addressing the issue. if the issue still persists Feel free to reach out if you need any further clarification or assistance.
Best regards,
Chaithra E. - v-echaithra
Community Support
Hi sasdfasdfsad ,
May I ask if you have resolved this issue? Please let us know if you have any further issues, we are happy to help.
Thank you.