This is basically a copy of sections of Ken Puls’ article at https://www.excelguru.ca/blog/2016/06/08/display-last-refreshed-date-in-power-bi/, in case that page is deleted or inaccessible. In his article, Ken discusses the finer points of the issues related to data pull timing versus local timing, and how to make it clear for users.
I’ve dealt with this in several environments. I strongly believe that the only way to ensure time consistency is to use UTC / GMT in the database, and let users (or their local application UI) make or control the conversion to display local time.
Storing local time in a database is a Horrible Idea for any nontrivial app. Not only will time zone issues be a problem for users in other time zones, but also Daylight Saving conversions can lead to gaps and apparent duplicates. Gaps and dupes due to Daylight Saving are easily recognized and forgiven by users during transactional processing after a time change, but historical reports are not so forgiving. Additionally, the time change occurs on different dates for different countries. UTC/GMT solves all of these problems.
Considering that, this method sets a DAY upon which the data was refreshed. The reports and dashboards that I create tend to cover 1-month periods, so the fact that the report is refreshed for the month is more important than the precise time it was refreshed.
Generate Last Refreshed Date with Power Query
Unlike the previous article, to work with Power BI, we need to generate the Last Refresh date ourselves using Power Query. No big deal, it is as simple as this:
- Open PowerBI Desktop
- Get Data –-> Blank Query
- Go to Home –> Advanced Editor and replace the code in the window with this:
let Source = #table(type table[LastRefresh=datetime], {{DateTime.LocalNow()}}) in Source
- Note; older versions of PowerBI Desktop required a leading “=” before the “let” keyword, although the leading “=” causes a “Token Literal expected” error in current versions of PowerBI.
- Click Done and rename the query “LastRefresh_Local”
- Click Close & Apply
Create the Last Refreshed Measure
To finish it off, we need to create a simple measure and add it to our dashboard.
- Go to your Report window –> New Measure –> Define it as follows:
Last Refreshed (Local) = FORMAT( LASTDATE(LastRefresh_Local[LastRefresh]) ,"mmm dd, yyyy hh:mm:ss AM/PM")
- Now let’s create a Card visual to hold it:
—- Back to my personal notes:
I like to format the card like so:
- In Data label, change Text size from 45pt to 12pt.
- Turn off Category.
- Turn on Title. Set Title text to “Data refreshed:”.
- Resize the card reasonably.
- Add a Notes page visible to the user that contains the card.
- Add a DevNotes page hidden to the user that contains a reference and hyperlink to these instructions, like so:
Date refresh source: https://www.excelguru.ca/blog/2016/06/08/display-last-refreshed-date-in-power-bi/