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.
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"
Solved! Go to Solution.
Yes, I have the value displaying on my reports so the user knows when the data was last refreshed
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)
Hi , please help me these,
instead of CentralTimeOffset which number values will gives exact sheduled refresh date time through server and how to add that time in power bi report
in M code Centaltimeoffset is Contains not correct please help me for these
Okay thanks. And this works for scheduled refreshes through the Power BI service?
Yes, I have the value displaying on my reports so the user knows when the data was last refreshed
That worked, thank you!
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.