Forum Discussion
Convert UTC to local time zone in DAX
Hi gjadal,
In DAX, there is no OOTB function for us to get local time zone. So we need to calculate the UTC datetime value use known time zone. Suppose the local time zone is UTC-8, to convert the UTC value to local datetime value, we can specify the DAX expression like below:
Column 4 = FORMAT(Table1[UTC],"MM/dd/YYYY") & " " & REPLACE(FORMAT(Table1[UTC],"HH:mm:ss"),1,2,HOUR(Table1[UTC])-8)
Then change this calculated column data type as Date/Time.
If you have any question, please feel free to ask.
Best Regards,
Qiuyun Yu
Hi Qiuyun,
Thanks for this post - could solve a problem I'd like to address.
I would like to show the "Last Refreshed DateTime" in my reports. I want this to provide the time in PST. The report is currently either refreshed via the Desktop (local to PST), or Online.
If I use NOW() in my report, I will get different times depending on whether where the refresh takes place. If via the desktop - NOW() is PST. If I use the schedule refresh, NOW() comes back in UTC time. M code using DateTime.LocalNow() has the expected same effect.
Is there M code to generate UTC time, then I can use your formula above to show the PST refresh time in the report?
Thanks!
Brian
- v-qiuyu-msft10 years ago
Community Support
Hi Virtual_Ames,
Please try to set the locale both in Power BI Desktop and Service. See: Supported languages and countries/regions for Power BI.
Best Regards,
Qiuyun Yu - eserapicos6 years agoNew Member
I have the same situation here... How to guarantee that the refresh time is the same among power BI desktop, app.powerbi or published web? Should I use other formula than NOW()?