Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi All,
I have a data model which is set to full refresh every day at 6 hrs interval, There is a ask to add a tile that gives the last refresh time for the data model in the Power BI report.
May I have help know how can we extract this refresh detail from Power BI service.
Output Required:
Solved! Go to Solution.
Hi @han_rj
You can create if with a blank query and this code in Power Query. Once produced just dragged the Last Refresh or Last Refresh Time field to a card.
let
Source = #table(type table[LastRefresh=datetime], {{DateTime.LocalNow()}}),
#"Added Custom" = Table.AddColumn(Source, "ZoneTime", each DateTime.AddZone([LastRefresh], 0)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "UTC", each -6),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"UTC", Int64.Type}}),
#"Added Custom2" = Table.AddColumn(#"Changed Type", "LastRefreshTime", each DateTimeZone.SwitchZone([ZoneTime],[UTC])),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom2",{{"LastRefreshTime", type datetimezone}, {"ZoneTime", type datetimezone}})
in
#"Changed Type1"
Note: On the Add Custom1 step I subtracted -6 to adjust to my time zone. Adapt it accordingly.
Proud to be a Super User!
Hi @han_rj
Thanks for reaching out to the Microsoft fabric community forum.
@lutz_bendlin @ray_aramburo Thanks for your Prompt Response
@han_rj ,
Below is the step-by-step guide to implementing it
Step-by-Step Guide
Step 1: Open Power BI Desktop
Step 2: Create a New Query
let
CurrentUTC = DateTimeZone.UtcNow(),
Year = Date.Year(CurrentUTC),
// DST starts: Second Sunday of March at 2 AM
DSTStart = Date.StartOfWeek(#datetimezone(Year, 3, 8, 2, 0, 0, 0, 0), Day.Sunday) + #duration(7, 0, 0, 0),
// DST ends: First Sunday of November at 2 AM
DSTEnd = Date.StartOfWeek(#datetimezone(Year, 11, 1, 2, 0, 0, 0, 0), Day.Sunday),
// Choose correct offset: -4 (EDT) or -5 (EST)
EasternOffset = if CurrentUTC >= DSTStart and CurrentUTC < DSTEnd then -4 else -5,
// Convert UTC to EST/EDT
EasternTimeWithZone = DateTimeZone.SwitchZone(CurrentUTC, EasternOffset),
// Remove time zone to keep the actual Eastern time
EasternTime = DateTimeZone.RemoveZone(EasternTimeWithZone),
// Format to text with AM/PM
FormattedEasternTime = DateTime.ToText(EasternTime, "dd-MM-yyyy hh:mm:ss tt"),
// Output as table
Last_Refresh_DateTime = Table.FromRecords({[LastRefresh = FormattedEasternTime]})
in
Last_Refresh_DateTime
Step 3: Load It Into Power BI
Step 4: Use It in Your Report
Step 5: Publish to Power BI Service
Step 6: Set up Scheduled Refresh (Optional)
We appreciate your engagement and thank you for being an active part of the community.
Best regards,
LakshmiNarayana.
Hi @han_rj ,
Thanks for getting back to me. Could you explain a bit more about the 4-hour window you mentioned?
Best Regards,
LakshmiNarayana
Hi @han_rj
Thanks for reaching out to the Microsoft fabric community forum.
@lutz_bendlin @ray_aramburo Thanks for your Prompt Response
@han_rj ,
Below is the step-by-step guide to implementing it
Step-by-Step Guide
Step 1: Open Power BI Desktop
Step 2: Create a New Query
let
CurrentUTC = DateTimeZone.UtcNow(),
Year = Date.Year(CurrentUTC),
// DST starts: Second Sunday of March at 2 AM
DSTStart = Date.StartOfWeek(#datetimezone(Year, 3, 8, 2, 0, 0, 0, 0), Day.Sunday) + #duration(7, 0, 0, 0),
// DST ends: First Sunday of November at 2 AM
DSTEnd = Date.StartOfWeek(#datetimezone(Year, 11, 1, 2, 0, 0, 0, 0), Day.Sunday),
// Choose correct offset: -4 (EDT) or -5 (EST)
EasternOffset = if CurrentUTC >= DSTStart and CurrentUTC < DSTEnd then -4 else -5,
// Convert UTC to EST/EDT
EasternTimeWithZone = DateTimeZone.SwitchZone(CurrentUTC, EasternOffset),
// Remove time zone to keep the actual Eastern time
EasternTime = DateTimeZone.RemoveZone(EasternTimeWithZone),
// Format to text with AM/PM
FormattedEasternTime = DateTime.ToText(EasternTime, "dd-MM-yyyy hh:mm:ss tt"),
// Output as table
Last_Refresh_DateTime = Table.FromRecords({[LastRefresh = FormattedEasternTime]})
in
Last_Refresh_DateTime
Step 3: Load It Into Power BI
Step 4: Use It in Your Report
Step 5: Publish to Power BI Service
Step 6: Set up Scheduled Refresh (Optional)
We appreciate your engagement and thank you for being an active part of the community.
Best regards,
LakshmiNarayana.
How can I change it to a 4 hours window
Obligatory warning: That Refresh timestamp is largely meaningless. Better find a date in your fact table that can indicate the actual freshness of the data.
Hi @han_rj
You can create if with a blank query and this code in Power Query. Once produced just dragged the Last Refresh or Last Refresh Time field to a card.
let
Source = #table(type table[LastRefresh=datetime], {{DateTime.LocalNow()}}),
#"Added Custom" = Table.AddColumn(Source, "ZoneTime", each DateTime.AddZone([LastRefresh], 0)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "UTC", each -6),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom1",{{"UTC", Int64.Type}}),
#"Added Custom2" = Table.AddColumn(#"Changed Type", "LastRefreshTime", each DateTimeZone.SwitchZone([ZoneTime],[UTC])),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom2",{{"LastRefreshTime", type datetimezone}, {"ZoneTime", type datetimezone}})
in
#"Changed Type1"
Note: On the Add Custom1 step I subtracted -6 to adjust to my time zone. Adapt it accordingly.
Proud to be a Super User!
User | Count |
---|---|
84 | |
79 | |
71 | |
48 | |
43 |
User | Count |
---|---|
111 | |
54 | |
50 | |
41 | |
40 |