Forum Discussion
TopN Dynamic Measure
- 3 years ago
Hi emmawdmi22
You need to have a separate disconnected table that contains the topn numbers to be used as a slices selection.
Create the following measure, place it in the filter pane of the table visual and select "Is not blank" then apply theFilter Measure = VAR N = SELECTEDVALUE ( Selection[Number] ) VAR CurrentRoom = VALUES ( 'Table'[Room] ) VAR SelectedRooms = ALLSELECTED ( 'Table'[Room] ) VAR T1 = ADDCOLUMNS ( SelectedRooms, "@TimesUsed", [Times Used] ) VAR T2 = TOPN ( N, T1, [@TimesUsed] ) VAR T3 = SELECTCOLUMNS ( T2, "@Room", [Room] ) RETURN COUNTROWS ( INTERSECT ( CurrentRoom, T3 ) ) - 3 years ago
emmawdmi22
Please tryFilter Measure = VAR N = SELECTEDVALUE ( Selection[Number] ) VAR CurrentRoom = VALUES ( 'Table'[Room] ) VAR SelectedRooms = CALCULATETABLE ( VALUES ( 'Table'[Room] ), ALLSELECTED () ) VAR T1 = ADDCOLUMNS ( SelectedRooms, "@TimesUsed", [Times Used] ) VAR T2 = TOPN ( N, T1, [@TimesUsed] ) VAR T3 = SELECTCOLUMNS ( T2, "@Room", [Room] ) RETURN COUNTROWS ( INTERSECT ( CurrentRoom, T3 ) )
Hi emmawdmi22
You need to have a separate disconnected table that contains the topn numbers to be used as a slices selection.
Create the following measure, place it in the filter pane of the table visual and select "Is not blank" then apply the
Filter Measure =
VAR N =
SELECTEDVALUE ( Selection[Number] )
VAR CurrentRoom =
VALUES ( 'Table'[Room] )
VAR SelectedRooms =
ALLSELECTED ( 'Table'[Room] )
VAR T1 =
ADDCOLUMNS ( SelectedRooms, "@TimesUsed", [Times Used] )
VAR T2 =
TOPN ( N, T1, [@TimesUsed] )
VAR T3 =
SELECTCOLUMNS ( T2, "@Room", [Room] )
RETURN
COUNTROWS ( INTERSECT ( CurrentRoom, T3 ) )- emmawdmi223 years agoHelper I
Thank you tamerj1 ! One more quick question that I forgot about. The original table has a date column. Is there an easy way to add this to your filter measure? When I select more than one date with it, all of the data shows instead of just the limited ones.
- tamerj13 years agoCommunity Champion
emmawdmi22
Please tryFilter Measure = VAR N = SELECTEDVALUE ( Selection[Number] ) VAR CurrentRoom = VALUES ( 'Table'[Room] ) VAR SelectedRooms = CALCULATETABLE ( VALUES ( 'Table'[Room] ), ALLSELECTED () ) VAR T1 = ADDCOLUMNS ( SelectedRooms, "@TimesUsed", [Times Used] ) VAR T2 = TOPN ( N, T1, [@TimesUsed] ) VAR T3 = SELECTCOLUMNS ( T2, "@Room", [Room] ) RETURN COUNTROWS ( INTERSECT ( CurrentRoom, T3 ) )