Forum Discussion
Refresh Power BI Dataset using Power Automate
- 1 year ago
Oh sorry. I forget that the power automate doesn't have all the requests from power bi rest api. You could do two things:
- Run an http request to power bi rest api to get that info like this link: https://learn.microsoft.com/en-us/rest/api/power-bi/datasets/get-refresh-history-in-group
- The alternative would be creating a table inside the dataset that has the datetime of the refresh. A table that has only one column and one value. Something like DateTime.LocalNow(). Once that's in the model. At Automate Create a variable with the datetime before running the refresh. After running the refresh, you can "Run a query against a dataset". Use DAX to get the value of that table of one row and one column. If the date is after the refresh was run, then it has finnished successfully. You might need a break by time know how long the refresh usually last because if it fails, the condition of checking if the date is older than the one in the query will never match.
I hope that helps
Hi mp390988
After the "Refresh a dataset" action in your flow, insert a "Get refresh history" action (Power BI connector) to retrieve the status of the dataset refresh.
Use a condition step to check if the latest refresh status equals "Failed."
Inside the condition, if the refresh status is "Failed," add an action to send an email.
Use the "Send an email (V2)" action from Outlook or any other mail connector.
In the email body, include relevant details such as dataset name, failure time, and error message if available.
Hi. Let me add something here. That's an approach but you need add something otherwise it might not work. After the refresh is requested, it will run the get history instantly. So the status would be running. No failed and no success. The flow might need a do while or loop to keep asking for the refresh history while the value is "running" or something like that.
Once it has finished you can take the value of the status and do whatever you want (send teams, mail, etc)
I hope that helps