Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Betsy
Helper IV
Helper IV

Convert UTC to client time zones?

Hi,

 

I have date/time information imported from csv files in UTC format. I also have imported time zone information for my various clients. What I'd like to do is create a series of calculated columns where date/time is reported in client time. So I could look at responses on Monday mornings vs. Friday mornings, for example. 

 

How would I do this?

 

Thanks for the help!

 

Betsy

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

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.

111.png
 

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)
222.png

 

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])
3333.png
 

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:
444.png
 

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

View solution in original post

27 REPLIES 27
hsantosh
Helper I
Helper I

Hi

I am building one report, report is embedded into application.

My requirement is report need to change dynamically as per the logged user time zone.

In application we have provision of changing time zones of user.

All power Bi services activities handled from India and users are the part of other countries time zones are EST,CST,HST and AKST

Is it achievable please suggest any solution.

Anonymous
Not applicable

Assumption:

You have a datetime column that YOU know is in UTC ( but probably power bi does not know that)

 

If you have a column in UTC, tell power bi so by creating a new colum called "utc_time" based on your prior utc column, use this code: DateTime.AddZone([ here put the name of your utc column ], 0 )

Abimael_0-1651268828667.png

 

Now you will notice some zeros:

Abimael_1-1651269051262.png

 

Change the data type to "date time zone":

Abimael_2-1651269077521.png

 

Now select the new column, go to Add Column> Time and click on "Local Time":

Abimael_3-1651269216323.png

This is the magic column that is useful for your reports, just change the name of the column (if you like) :

Abimael_4-1651269440434.png

 

 

 

Jay7
Frequent Visitor

I had to display last refreshed time in the report. When I published from my local machine, it had Eastern time zone. However, when it was schedule refreshed in Power BI Server, it displayed UTC time.

 

I modified current time logic as below:

 

DateTimeZone.RemoveZone(DateTimeZone.SwitchZone(DateTimeZone.UtcNow(),10))

 

1. Get UTC time

2. Switch zone to Eastern zone (+10:00)

3. Remove zone from the date time(If I dont do this, it displays UTC time with +10:00. When I changed it's type to DateTime or text, it did not work)

 

You can use "DateTimeZone.From" if you already have the date and time. I haven't tested this though. 

Anonymous
Not applicable

You stated:

""You can use "DateTimeZone.From" if you already have the date and time. I haven't tested this though.""

 

This worked for me, I had the [UTC DateTime] field and I was able to use DateTimeZone.From to convert the UTC (as text) to a new (local) [DateTime] (as DateTimeZone) field.

 

BUT - if your UTC comes with a TZ (time zone offset), this function does NOT take that into account. It just parses the DateTime and does not use the offset to adjust the result to the local time...

 

Which I am working on figuring out how to do.

 

 

 

v-caliao-msft
Microsoft Employee
Microsoft Employee

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.

111.png
 

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)
222.png

 

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])
3333.png
 

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:
444.png
 

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

Firstly, really great workaround what you did there. I have seen several posts but they look like they lack the Day light saving(DLS) into consideration. This Solution worked for me with DLS as well.

The question i have is, I am trying to do the same but not on power BI desktop rather on DataFlows. I know that power BI service always considers 'UTC' as its local time. I was trying to see other approach for this problem. It is essential for me to convert this to my local (Pacific time) in dataflow as I want to limit my rows based off of this date time column dynamically. 

Any suggestions or approaches to handle this? thanks in advance

Is it just me, or is this an insane amount of work to do something that should be out of the box?  Power BI seems to have suggestions that are WAY over engineered for something that Tableau can do without even thinking.

@v-caliao-msftCan we get the user's location and display the date and time column accordingly with the dynamic approach

Anonymous
Not applicable

@v-caliao-msft / Charlie Liao

Is it planned to provide an implementation by Microsoft for

Power BI service to evaluate the browser time zone settings?

 

Best would be:

  1. Get the current time zone setting of the connected browser
  2. Allow (via dedicated datetime methods) filtering and display to use that request specific user time zone

= Users from Australia see the same reports as those from Europa as those from the USA.
But: Those from Australia with the appropriate Australian time zone, those from Europe ...

 

Example:

The very same record would show 01:40 May 1, 2018 in Australia
But: 17:40 April 30, 2108 in Switzerland

And: 11:40 April 30, 2018 in New York

 

Regards, David

Has this been resolved? Also have a need for this. 

Anonymous
Not applicable

 I have a similar business need to be implemented. Have you been able to figure this issue? 

@v-caliao-msft  I don't have a UTC column, could you describe how to invoke that? 

If you have a local datetimezone, then you can convert it to UTC using DateTimeZone.ToUtc:

 

let
    Source = #table(type table[LocalDateTimeZone = datetimezone],{{#datetimezone(2017,12,6,11,30,15,-4,-30)}}),
    AddedUTC = Table.AddColumn(Source, "UTC", each DateTimeZone.ToUtc([LocalDateTimeZone]))
in
    AddedUTC

 

Specializing in Power Query Formula Language (M)

I have followed this process successfully at the query level.  However, when referencing the ClientTime in a report, the time zone information is stripped out and the fields revert to Date/Time from the Date/Time/Timezone format; times revert to UTC.

How can this data be used in a report?  Is this a known issue with Power BI?

Having a similar issue, when I'm in the Query Editor and convert the column type to "Date/Time/Timezone" it shows the proper -05:00. However on the actual report as a Date/Time it shows UTC.

Hmm. I didn't have that issue, but I ran the client time as a one off report, so I deleted the UTC time column after I converted a client time replacement. I wonder if that makes a difference?

Hey @ppfisterer,

 

Is your report in the service? I had no issues making the report using client time on the desktop, with the caveat that I created a time reference table with the hours listed, that I then related the client time transformation back to, That may help with the time conversion issue (I use both time and date reference tables to tie my various tables together. I found time, in the general sense, to not work very well in BI without them).

 

Betsy

Betsy,

yes, I have both time and date reference tables.   I duplicated the UTC column in the souce table twice. In one column apply Date and in the second apply Time.  The values there respect the time zone.  If I then reference these new columns in a table in the report, they no longer reflect the adjusted time zone but show the UTC time again.  The original field with Date/Time/Timezone format does look ok .  Here are the steps from the query editor

= Table.DuplicateColumn(#"Added Custom2", "RoomTimeStamp", "RoomTimeStamp - Copy")

= Table.RenameColumns(#"Duplicated Column",{{"RoomTimeStamp - Copy", "RoomStartDate"}})

= Table.TransformColumnTypes(#"Renamed Columns",{{"RoomStartDate", type date}})

 

= Table.DuplicateColumn(#"Changed Type", "RoomTimeStamp", "RoomTimeStamp - Copy")

= Table.RenameColumns(#"Duplicated Column1",{{"RoomTimeStamp - Copy", "RoomStartTime"}})

= Table.TransformColumnTypes(#"Renamed Columns2",{{"RoomStartTime", type time}})

 

UTC  = 11/19/2016 4:25:43 AM +00:00

for E. Australia Standard Time 10      

RoomTimeStamp = 11/19/2016 2:25:43 PM +10:00 

RoomStartDate = 11/18/2016   ??

RoomStartTime = 11:25:43 PM   ??

 

The RoomTimeStamp is correct but when the values have types applied as Date or Time, the data doesn't make sense.

 

-Phil

Instead of applying a different Type to the column, a Transform to extract the date and time seems to do the trick.

Hi @v-caliao-msft
This solution is perfect, but I am struggling with Daylight saving time. My data is in UTC and I want to convert it into EDT and EST repsectively. Therefore from Mar - Nov I want EDT data i.e. UTC - 4:00, whereas from Nov - Mar I want EST date i.e. UTC - 5:00. Is there any wany I can get it fixed in Power BI.
Thanks in advance. Any help is appreciated.

Regards,
Sahil

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.