Hi everyone,
To make it easy to find here’s a Power Query M query to generate a “Last refresh” table.
And if you want to give that a try, go to Power Query, select New Source, Blank Query, open the Advanced Editor (select everything) and past this in:
let
Source = DateTime.FixedLocalNow(),
#"Converted to Table" = #table(1, {{Source}}),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table", {{"Column1", "Last Refresh"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns", {{"Last Refresh", type datetime}}),
#"Inserted Date" = Table.AddColumn(#"Changed Type", "Date", each DateTime.Date([Last Refresh]), type date),
#"Insert Time" = Table.AddColumn(#"Inserted Date", "Time", each DateTime.Time([Last Refresh]), type time)
in
#"Insert Time"
.
The result will be a table like this and it will be updated every time the Query (Data model) is refreshed.
Let me admit, I created a habit of including a table like this in all my Models and Dataflows and I still find it useful today. Know that you don’t need to create any connections to this table - it’s a supporting table. You can even hide it completely in Report View!
Of course I’m aware of the fact that, with the ‘new look’ enabled, a report refresh date will be shown in the Power BI Service too BUT what if my Dataflow failed and my Report didn’t? Who’s to know?
Another plus, in my opinion, is that you can reference this date instead of using the TODAY() function. Same reason really, if the refresh fails the DAX function doesn’t know or care… That function has only one job and is pretty good at it - you’ve guessed it! - returning today’s date.
So how do you reference this Last Refresh date? Easy, just create a simple measure something like:
Last Refresh Date =
MAX( Last Refresh[Date] )
And now you can reference this [Last Refresh Date] measure instead of using TODAY()
.
There’s also video on creating a Last Refresh table in Power Query that includes how to deal with Timezones, you can find that here.
Big thanks to @JarrettM for sharing it with the community!
.
Let me know if you’ve enjoyed this.