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

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.

Reply
Daven
Helper II
Helper II

UTC to Local as measure

Hi,

 

Is there a way to change UTC to local as a measure?

 

Thanks,

 

Daven

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Daven ,

You can create a measure like this:

Local Time =
CONVERT (
    FORMAT ( SELECTEDVALUE ( 'Table'[UTC] ), "MM/dd/YYYY" ) & " "
        & REPLACE (
            FORMAT ( SELECTEDVALUE ( 'Table'[UTC] ), "HH:MM:SS" ),
            1,
            2,
            HOUR ( SELECTEDVALUE ( 'Table'[UTC] ) ) - 8
        ),
    DATETIME
)

The number "-8" depends on your local timezone.

time.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @Daven ,

You can create a measure like this:

Local Time =
CONVERT (
    FORMAT ( SELECTEDVALUE ( 'Table'[UTC] ), "MM/dd/YYYY" ) & " "
        & REPLACE (
            FORMAT ( SELECTEDVALUE ( 'Table'[UTC] ), "HH:MM:SS" ),
            1,
            2,
            HOUR ( SELECTEDVALUE ( 'Table'[UTC] ) ) - 8
        ),
    DATETIME
)

The number "-8" depends on your local timezone.

time.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Vingjie,

 

Thanks for your response. I am getting an error and believe its because my dataset has UTC in datetime year to fraction (3).  How do I convert it to Datetime? I am using directquery so unable to do any transformation. Has to be as a measure. 

 

i.e UAT format: 2021-01-02T00:03:05.1330000

Daven_0-1612369323751.png

 

 

Thank you so much for your help

 

Daven 

Yes. You can work out your time zone and make an an adjustment for the time using the TIME() function. But maybe it is better to convert it prior to load using Power Query. 



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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