Forum Discussion
Convert UTC to client time zones?
- 10 years ago
Hi Betsy,
We may take a try with the method below:
Assuming currently we have the Time and UTC column in a table, where [Time] stores the actual UTC time, [UTC] stores the changed hour count between client and UTC.
Based on the different Time Zone, UTC values changes within -12 to 12 range.
When data loaded into Power BI, open Query Editor, under the Add column tab, click Add Custom Column, then under the formula part, copy and paste the following:
DateTime.AddZone([Time],0)Click OK. This step adds the default UTC Time Zone (0 here) under the time stored in [Time], to the newly created ZoneTime column;
After that, we need to create another column to switch the time zone to the client, also click on the Add custom column, then copy and paste the following formula:
DateTimeZone.SwitchZone([ZoneTime],[UTC])
After that, we have successfully added the time Zone information into the time. Then we need format the column into date/time/timezone format.
Select ClientTime column, navigate to Transform tab, choose data type and select Date/Time/TimeZone:
After that, click close and apply.
Till then we should have finished converting the time into Client local time.
If any further questions, please feel free to post back.Regards,
Charlie Liao
Another great post. I see you are using [Offset After] . How exact is this feature used?
= Table.AddColumn(
ChangedTypeToDateTime,
"Eastern Date Time",
(ThisRow) =>
ThisRow[UTC DateTime] +
List.Last(
Table.SelectRows(
ClockSwitchesEasternTime,
each [UTC] <= ThisRow[UTC DateTime])[Offset After]
),
type datetimeThe part
Table.SelectRows(ClockSwitchesEasternTime, each [UTC] <= ThisRow[UTC DateTime])
returns a table.
By adding [Offset After], the "Offset After" column of that table is returned as a list of values (i.c. durations).