Forum Discussion
Showing visual in different timezone based on slicer selection or RLS
- 4 years ago
Hi WHENG ,
This code to change the bar chart.
Bar chart = VAR _datetime = SWITCH( SELECTEDVALUE( Timezone[Timezone] ), "Asia/Singapore", TIME( 8, 0, 0 ), "Asia/Bangkok", TIME( 7, 0, 0 ), 0 ) RETURN COUNTROWS( FILTER( UTC, DATE( YEAR( [Start date UTC] + _datetime ), MONTH( [Start date UTC] + _datetime ), DAY( [Start date UTC] + _datetime ) ) >= MIN( 'Calendar'[Date] ) && DATE( YEAR( [Start date UTC] + _datetime ), MONTH( [Start date UTC] + _datetime ), DAY( [Start date UTC] + _datetime ) ) <= MAX( 'Calendar'[Date] ) ) )Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi WHENG ,
The place of the max() is the same as selectedvalue(). But max() return the maxnium date in the date column of current row Event ID, For example, event id is I-0001 and it has one rows in events table, which row's date has one value 1/1/2022 4:00pm, so the max() date is 1/1/2022 4:00pm, it returns 1/1/2022 4:00pm. But if this event-id has two rows, it will return only one of them.
change the chart visual (e.g line or bar) as well according to the selected Timezone too
Please provide the measure of count. Or some measure like this:
measure =
VAR _switchtime =
SWITCH( TRUE(), "Asia/Singapore", 8, "Asia/Bangkok", 7, 0 )
RETURN
COUNTROWS(
FILTER(
'event table',
( [start date] - _switchtime )
<= MAX( calendar[date] )
&& ( [start date] - _switchtime )
>= MIN( calendar[date] )
)
)
item 3# RLS:
get the default timezero =
VAR _d =
CALCULATE(
MAX( 'usertimezero' ),
FILTER( usertimezero, [useremail] = USERPRINCIPALNAME() )
)
VAR _a =
SWITCH(
_d,
"Asia/Singapore", CALCULATE( MAX( SGT[Start date] ) ),
"Asia/Bangkok", CALCULATE( MAX( THT[Start date] ) ),
CALCULATE( MAX( UTC[Start date] ) )
)
RETURN
IF( SELECTEDVALUE( Timezone[Timezone] ) = BLANK(), _a, [Start date] )
if you need more help , you can share pbix file without sensitive data.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi v-chenwuz-msft,
Please find the pbix file below
https://drive.google.com/file/d/1BLrhQNP5FSHdLfnqae5eSBCQcpUFXr9d/view?usp=sharing
I got this error on the measure
I couldn't use measure as the axis for the chart visual (e.g line or bar).
Another way i can do is using bookmark to show the selected timezone chart. But it will become hard to manage if more timezone added. Bookmark doesn't change according to slicer as well
Appreciate your advice
Thank you
- v-chenwuz-msft4 years ago
Community Support
Hi WHENG ,
This code to change the bar chart.
Bar chart = VAR _datetime = SWITCH( SELECTEDVALUE( Timezone[Timezone] ), "Asia/Singapore", TIME( 8, 0, 0 ), "Asia/Bangkok", TIME( 7, 0, 0 ), 0 ) RETURN COUNTROWS( FILTER( UTC, DATE( YEAR( [Start date UTC] + _datetime ), MONTH( [Start date UTC] + _datetime ), DAY( [Start date UTC] + _datetime ) ) >= MIN( 'Calendar'[Date] ) && DATE( YEAR( [Start date UTC] + _datetime ), MONTH( [Start date UTC] + _datetime ), DAY( [Start date UTC] + _datetime ) ) <= MAX( 'Calendar'[Date] ) ) )Result:
Pbix in the end you can refer.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- WHENG4 years agoFrequent Visitor
Hi v-chenwuz-msft,
Thanks a lot! - WHENG4 years agoFrequent Visitor
Hi v-chenwuz-msft,
When a date slicer was added to filter the data (considering more data are added in the future). the table and chart doesn't show correctly anymore.
A relationship between the Calendar[Date] and UTC[Start date UTC] is breaking the table/chart too
https://drive.google.com/file/d/1eRFOdOpQRkWKrB2EX26IvRwpkO5bgV69/view?usp=sharingYour advice would be much appreciated
Thank you