Forum Discussion
Convert UTC date time to local user time
Hello,
I want to convert UTC datetime to local datetime according to the user's location.
For that I do an upstream conversion on power query and it works well in desktop but when I publish the dataset on power bi service the conversion is not taken into account anymore, the dates remain in UTC
I even tried to manipulate the hours directly, which works well in desktop with the request below but not in service :
DateTimeZone.RemoveZone(DateTimeZone.SwitchZone(DateTime.AddZone([time],0),Time.Hour(DateTimeZone.LocalNow())-Time.Hour(DateTimeZone.UtcNow()))))
Any hints please?
2 Replies
- Anand24Super User
Hi Anonymous ,
Power BI Services automatically converts date/datetime to UTC timezone irrespective of what timezone you set in the .pbix file.
To achieve your desired timezone in services, create a new date measure/column by adding/subtracting hours from UTC timezone.
Example: For Brazil Timezone,
Using DAX, New Date measure would be Brazil_DateTime = UTC_DateTime + (3/24)
Using M Code in Power Query Editor, it would be New Date Column = DateTime.AddZone([UTC_DateTime],3)
Give a Thumbs Up if this post helped you in any way and Mark This Post as Solution if it solved your query !!!
Proud To Be a Super User !!!
LinkedIn- AnonymousNot applicable
Hi Anand24,
Thanks for the answer. But the report is used by several users from different countries and therefore uses data from the same date column