Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MrCrow
Helper I
Helper I

Use Automate to send a daily email only if a power bi database refresh succeeded

Hey there!

 

Making a automated daily infographic for my company.   Every once in a while the scheduled refresh will fail (usually a error with getting the data report from our companies database).      I dont want my daily report to send if the database did not refresh properly.   Currently i have Power BI report subscribed to send to my own email, then i use power automate to download the .png attachment and use html code to put it in the body of a sent email in a nice and clean finished report.   

 

I was playing around with conditions for it to see if i got a "refresh failed" email that day but i couldnt figure it out.  Is there a way you may know about to conditionally run the power automate, or subscribed report daily?   

4 REPLIES 4
sunnyujjawal
New Member

Yes, you can add a condition to your Power Automate flow to check if the data refresh was successful before sending the email with the Power BI report.

Here's an example of how you can do this:

  1. Add a "Recurrence" trigger to your Power Automate flow to run daily.
  2. Add an action to the flow to get the refresh history of the dataset from the Power BI API. You can use the "HTTP" action and call the "Get Refresh History In Group" API endpoint. You will need to provide the Group ID and Dataset ID for your Power BI report in the request URL.
  3. Parse the response from the API using the "Parse JSON" action to extract the status of the last refresh.
  4. Use a condition action to check if the status of the last refresh is "Succeeded". If it is not, then you can end the flow without sending the email.
  5. If the refresh was successful, then add the actions to download the PNG attachment and send the email with the report as you currently have in your flow.

Here's a sample JSON schema for the response from the Power BI API that you can use in the "Parse JSON" action:

 

{
"type": "array",
"items": {
"type": "object",
"properties": {
"id": { "type": "string" },
"startTime": { "type": "string" },
"endTime": { "type": "string" },
"status": { "type": "string" }
},
"required": ["id", "startTime", "endTime", "status"]
}
}

 

You can use the "status" property to check if the last refresh was successful.

Can you please elaborate this solution with an example screen shot?

Hi @sunnyujjawal

Can you help me for describe the flow

Wicak_0-1686994321150.png

I've made the flow but can't control when the data refresh fails then the report will still be sent.

Thank you for taking your time to reply 🙂

ooooh this seems promising!   Never ran aything like this so it may take a bit, but ill follow up when i figure it out 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors