Forum Discussion

mp390988's avatar
mp390988
Post Partisan
1 year ago
Solved

Refresh Power BI Dataset using Power Automate

Hi,

 

I created a flow in Power Automate to refresh a power bi dataset.

The issue I am having is that sometimes the flow fails and as a result the dataset is not refreshed.

I want to set up an alert, ideally an email to get sent when the flow fails to refresh the dataset.

 

This is my flow so far:

 

 

What steps do I need to add to configure the alert when it fails?

 

Thank You

  • ibarrau's avatar
    ibarrau
    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

10 Replies

  • 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.

    • ibarrau's avatar
      ibarrau
      Super User

      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

    • mp390988's avatar
      mp390988
      Post Partisan

      Hi,

       

      I don't see "Get refresh history" under the Power BI connector. This is what I see under the Power BI connector:

      Thanks

      • ibarrau's avatar
        ibarrau
        Super User

        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

  • If the flow is what is failing as opposed to the refresh, what you are looking for is the send an email connector, and set it to only runif the previous step has failed. 

     

    • xaviernt's avatar
      xaviernt
      Frequent Visitor

      This doesn't work because the node in Power Automate return successful status when it successfully send the request for the semantic to refresh, not when the semantic model successfully refreshed. So if there's an error and the Power BI semantic model didn't refresh, it won't reflect that in Power Automate.

  • v-lgarikapat's avatar
    v-lgarikapat
    Community Support

    Hi mp390988 ,

    Thanks for reaching out to the Microsoft fabric community forum.

    ibarrau , MohamedFowzan1 ,

    Thanks for your prompt response

    In addition to  ibarrau , and MohamedFowzan1 , I have added the previously solved threads and learning documents, which can be helpful in understanding and resolving the issue.

    Solved: Dataset Refresh Failure Notification Through Dataf... - Microsoft Fabric Community

    Solved: Flow to refresh dataflow and dataset in PowerBI Issue

    Power BI dataset Refresh failure notification when... - Microsoft Fabric Community

    Datasets - Get Refresh History - REST API (Power BI Power BI REST APIs) | Microsoft Learn

     

    Best Regards,

    Lakshmi

    • v-lgarikapat's avatar
      v-lgarikapat
      Community Support

      Hi  mp390988 , 

       

      We haven’t heard back from you regarding our last response, so I just wanted to check in to see if you were able to resolve the issue. If you have any further questions or need assistance, please feel free to let us know.

      Best Regards,

      Lakshmi

       

       

      • v-lgarikapat's avatar
        v-lgarikapat
        Community Support

        Hi mp390988 ,

         

        We haven’t heard back from you regarding our last response, so I just wanted to check in to see if you were able to resolve the issue. If you have any further questions or need assistance, please feel free to let us know.

        Best Regards,

        Lakshmi