Forum Discussion
Show Date/time based on user's time zone
- 2 years ago
Hi Anonymous
While M has built-in functions to handle timezones, none of them automatically shifts to the user's. The service uses Utc while Desktop is the user's. M will not know what timezone those datetimes are in so any datetime column converted to datetimezone will be +0 if refreshed in the service. You can convert a datetime column to datetimezone with an offset value (like 10.5 for GMT+10:30) using DateTimeZone.AddZone but knowing what timezone to add is key. Either way, you get to select and load only a specific timezone - Utc or user-defined.
Hi danextian,
Sorry for asking lots of questions, but I'm a little confused.
I couldn't set a many to many relationship here and also I don't know how to connect the time zone column with our crossjoined table.
In the demo file you sent me, I added a new graph to show the switched time zones.
Could you please help me with how I should do this?
I couldn't upload a pbix file here so here's the link to transferxl.
There's something I miss in the formula. I forgot to add the datetime based on the selected timezone. Should have been:
Crossjoined Table =
VAR Timezones =
SELECTCOLUMNS ( GENERATESERIES ( -23.5, 23.5, 0.5 ), "TimeZone", [Value] )
VAR DistinctDateTimes =
DISTINCT ( 'fact table'[datetime] )
RETURN
ADDCOLUMNS (
CROSSJOIN ( Timezones, DistinctDateTimes ),
"Switched DateTime", [DateTime] + DIVIDE ( [TimeZone], 24 )
)
Please see attached sample pbix