cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
i820017
Resolver II
Resolver II

Refresh Issues

Hey Everybody,

I am having trouble with my M-code. I am creating a timestamp to use in the cloud that shows the refresh time for Power BI reports. 

Here is my M-code.

 

let
SummerTime = Date.StartOfWeek(#date(Date.Year(DateTime.LocalNow()),3,14), Day.Sunday),
WinterTime = Date.StartOfWeek(#date(Date.Year(DateTime.LocalNow()),10,14), Day.Sunday),
CurrentDateTime = DateTimeZone.RemoveZone(DateTimeZone.UtcNow()),
TimeShiftFromUTC = if CurrentDateTime < SummerTime & #time(1, 0, 0) or
CurrentDateTime > WinterTime & #time(1, 0, 0) then
1 else 2,
TimeStamp = DateTimeZone.SwitchZone( DateTimeZone.UtcNow(), TimeShiftFromUTC, 0),
#"Converted to Table" = #table(1, {{TimeStamp}}),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "Time Stamp"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"Time Stamp", type datetimezone}})
in
#"Changed Type"

 

Here is my output.

i820017_0-1636397347908.png

 

Currently, I am in Chicago, and the time should have read 12:46:51 PM. However, I want the time to be in EST. Consequently, the above output should be 1:46:51 PM (if everything is correct). 

Can anyone give me help with my above M-code so that it works all year round?

 

Thanks

Dan

1 ACCEPTED SOLUTION
GilbertQ
Super User
Super User

Hi @i820017 

 

Here is my blog post where I detailed how to achieve this, it should help

 

Using Power BI to ensure Daylight Savings Dates and Times change dynamically - Reporting/Analytics M...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

1 REPLY 1
GilbertQ
Super User
Super User

Hi @i820017 

 

Here is my blog post where I detailed how to achieve this, it should help

 

Using Power BI to ensure Daylight Savings Dates and Times change dynamically - Reporting/Analytics M...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!