cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
mterry Member
Member

Time Zones and Scheduled Refresh

I created a table to show the latest refresh day and time for my reports, had issues when I scheduled a refresh through the Power BI service, and reading through here found the cause of the error (I believe). In the code below the LocalNow() portion is using UTC time when the refresh gets scheduled through the service whereas it's using my time on my local machine through the desktop app. 

 

= #table(type table[LastRefresh=datetime], {{DateTime.LocalNow()}})

 

So I updated my table to pull the UTC date & time, then added a column that adjusted the time zone. However, I'm still having issues, and I don't understand why, code is pasted below. If I'm using the Utc time as an anchor, why is my 'LastRefreshLocal' column still pulling UTC time instead of switching to my local time zone?

 

let
Source = #table(type table[LastRefresh=datetimezone], {{DateTimeZone.UtcNow()}}),
#"Added Custom" = Table.AddColumn(Source, "LastRefreshLocal", each DateTimeZone.SwitchZone([LastRefresh],-6,0)),
#"Renamed Columns" = Table.RenameColumns(#"Added Custom",{{"LastRefresh", "LastRefreshUTC"}}),
#"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"LastRefreshLocal", type datetimezone}})
in
#"Changed Type"

 

1 ACCEPTED SOLUTION

Accepted Solutions
blopez11 Established Member
Established Member

Re: Time Zones and Scheduled Refresh

Yes, I have the value displaying on my reports so the user knows when the data was last refreshed

4 REPLIES 4
blopez11 Established Member
Established Member

Re: Time Zones and Scheduled Refresh

Here are the M steps that I used that seem to work fine (CentralTimeOffset is a parameter)

Though they don't look much different to what you are doing

Good Luck

 

#"Added Refresh Date Time (UTC)" = Table.AddColumn(#"Changed Type", "Refresh Date Time (UTC)", each DateTimeZone.UtcNow(), type datetimezone),
#"Added Refresh Date Time (CST)" = Table.AddColumn(#"Added Refresh Date Time (UTC)", "Refresh Date Time (CST)", each DateTimeZone.RemoveZone ( DateTimeZone.SwitchZone ( [#"Refresh Date Time (UTC)"], -CentralTimeOffset ) ), type datetime)

mterry Member
Member

Re: Time Zones and Scheduled Refresh

Okay thanks. And this works for scheduled refreshes through the Power BI service?

blopez11 Established Member
Established Member

Re: Time Zones and Scheduled Refresh

Yes, I have the value displaying on my reports so the user knows when the data was last refreshed

mterry Member
Member

Re: Time Zones and Scheduled Refresh

That worked, thank you!