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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Lexixl
Frequent Visitor

How to Create an Refresh Failed message in the Text Box in Power BI Desktop

Hi

I have a report connect to the Azure Sql Database. And I schudle the refresh time in Power BI Service. However, sometimes the scheduled refresh failed and the report can't be refreshed to the most recent data.

For now, our customer wants to see an error message like 'the data is not to date' in the report when the refresh failed. But when the report refresh successfully, this message will be hidden. 

 

I'm trying to create the refresh time table depends on the local time and want to add an column to show whether the local time is in the refresh time span (From 8:30 am to 12:30 pm) as below: 

Lexixl_1-1628740032446.png

 

Lexixl_0-1628739964501.png

But it gives me an error and I'm not sure it's a good way to solve this issue.

 

Is it possible to do as my customer expect?

 

Thank you so much for your help.

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey @Lexixl , from the screenshot you provided it seems you are using DAX function and syntax to calculate the column you want inside Power Query. Either you change to M functions / M syntax (M is the language you can use together with Power Query, or you use DAX to create a calculated column or measure.

 

Nevertheless, I tend to use a mixture. I use Power Query (M) to create a table that just contains a single row and a single column.

This is the M code to create this table:

 

let
    Source = Table.FromRecords({[RefreshDateTime = DateTime.LocalNow()]}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"RefreshDateTime", type datetime}})
in
    #"Changed Type"

 

Just Copy/Paste the code to a blank query using the Advanced Editor inside Power Query.

Whenever the data will be refreshed successfully this table contains a datetime value that corresponds to the latest refresh. Please be aware that I name the table "RefreshDateTime"

 

Then you can use DAX code to create a measure similar to this:

 

CurrentOrNot = 
var LatestRefreshDateTime = MAX( 'RefreshDateTime'[RefreshDateTime] )
var CurrentDateTime = NOW()
var Difference = DATEDIFF( LatestRefreshDateTime , CurrentDateTime , MINUTE )
return
IF( Difference < 60 , "current" , "not current")

 

 

Hopefully, this provides some ideas on how to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

2 REPLIES 2
TomMartens
Super User
Super User

Hey @Lexixl , from the screenshot you provided it seems you are using DAX function and syntax to calculate the column you want inside Power Query. Either you change to M functions / M syntax (M is the language you can use together with Power Query, or you use DAX to create a calculated column or measure.

 

Nevertheless, I tend to use a mixture. I use Power Query (M) to create a table that just contains a single row and a single column.

This is the M code to create this table:

 

let
    Source = Table.FromRecords({[RefreshDateTime = DateTime.LocalNow()]}),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"RefreshDateTime", type datetime}})
in
    #"Changed Type"

 

Just Copy/Paste the code to a blank query using the Advanced Editor inside Power Query.

Whenever the data will be refreshed successfully this table contains a datetime value that corresponds to the latest refresh. Please be aware that I name the table "RefreshDateTime"

 

Then you can use DAX code to create a measure similar to this:

 

CurrentOrNot = 
var LatestRefreshDateTime = MAX( 'RefreshDateTime'[RefreshDateTime] )
var CurrentDateTime = NOW()
var Difference = DATEDIFF( LatestRefreshDateTime , CurrentDateTime , MINUTE )
return
IF( Difference < 60 , "current" , "not current")

 

 

Hopefully, this provides some ideas on how to tackle your challenge.

 

Regards,

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
AllisonKennedy
Super User
Super User

@Lexixl I'm a bit confused on what your date table date is representing? Would it be sufficient to calculate the last Refresh time and compare that to current time? You will need to use DAX for this to calculate UTCNOW and compare that to the refresh time in UTC. Display Last Refreshed Date in Power BI - The Excelguru BlogThe Excelguru Blog

 

Then use DAX to create the error message, or even just display the last refresh time. Would that work?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.