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
bryanc78
Helper IV
Helper IV

Show report last refreshed time in local time?

What's the best way to show the last time a report was refreshed and have that time be the local time, not UTC, after a scheduled refresh?

 

I've seen multiple solutions but none work once a scheduled refresh occurs.  M code preferred

 

Thanks!

5 REPLIES 5

I use this function to adjust UTC to EST in a column. I believe I got some of this from @MarcelBeug

 

let
ESTAdjustment = (InputDateTimeAsUTC as datetimezone, UTCAdjustmentAmount as number) =>
let
CurrentYear = Date.Year( DateTimeZone.SwitchZone( InputDateTimeAsUTC, UTCAdjustmentAmount ) ),
DaylightSavingsStart = Date.StartOfWeek( #datetimezone( CurrentYear, 3, 14, 0, 0, 0, UTCAdjustmentAmount, 0 ), Day.Sunday ) + #duration( 0, 2, 0, 0 ),
DaylightSavingsEnd = Date.StartOfWeek( #datetimezone( CurrentYear, 11, 7, 0, 0, 0, UTCAdjustmentAmount + 1, 0 ), Day.Sunday ) + #duration( 0, 2, 0, 0 ),
AdjustForDaylightSavingsTime = if InputDateTimeAsUTC >= DaylightSavingsStart and InputDateTimeAsUTC < DaylightSavingsEnd then UTCAdjustmentAmount + 1 else UTCAdjustmentAmount,
AdjustToEST = DateTimeZone.RemoveZone(InputDateTimeAsUTC) + #duration(0, AdjustForDaylightSavingsTime, 0, 0)
in
AdjustToEST
in
ESTAdjustment

amitchandak
Super User
Super User

@bryanc78 , now() in Dax and Datetime.LocalNow() Can help

Please check detailed steps at

https://www.enhansoft.com/how-to-add-the-last-refreshed-date-and-time-to-a-power-bi-report/

@amitchandak  This did not work as it kept the time in UTC

I was able to get the refresh time added and then subtract the hours needed for my time zone but day light savings time will make it wrong again.

Any other solutions?
Greg_Deckler
Super User
Super User

@bryanc78 - I think use UTCNOW and you can add/subtract the hours. I believe there is an equivalent in Power Query, like DateTime.LocalNow, let me check.

https://docs.microsoft.com/en-us/powerquery-m/datetime-localnow

 

There is also FixedLocalNow and again, can add/subtract #duration()


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.