Forum Discussion
default slicer top N value
Hi All,
I have a table visual and a slicer to so select the top N value, How can i default the slicer to show top15 please?
Thanks
Ammy
- Anonymous6 years agoHi Ammy,We can do the same dynamically, so the user can select top value.Please follow the following steps:Create the following measure for calculating the rank:Rank By Amount =RANKX(ALL('Table_Name'[comp_name]), [amount],,DESC)Then create a table with one column. (You can use Enter Data option in Power BI)For ex use the name Top for both table name and column name.Insert values like 10, 20, 30, .... 200.Use this table values for filtering dynamically.Then create the second measure:Selected Top N Value = SELECTEDVALUE('Top'[Top])Then create one more measure measure:comp_name Included = IF([Rank By Amount] <= [Selected Top N Value],1,0)And add this measure in Filters pane and set the value equal to 1.Please refer the following image for reference.
7 Replies
- AnonymousNot applicableHi Ammy,We can do the same dynamically, so the user can select top value.Please follow the following steps:Create the following measure for calculating the rank:Rank By Amount =RANKX(ALL('Table_Name'[comp_name]), [amount],,DESC)Then create a table with one column. (You can use Enter Data option in Power BI)For ex use the name Top for both table name and column name.Insert values like 10, 20, 30, .... 200.Use this table values for filtering dynamically.Then create the second measure:Selected Top N Value = SELECTEDVALUE('Top'[Top])Then create one more measure measure:comp_name Included = IF([Rank By Amount] <= [Selected Top N Value],1,0)And add this measure in Filters pane and set the value equal to 1.Please refer the following image for reference.
- AnonymousNot applicable
Hi
In this exmple is it deafulting to top 10 ? Thanks
- AnonymousNot applicable
You can add one more measure for default value.
Selected Top N Value New = IF(HASONEVALUE('Top'[Top]), SELECTEDVALUE('Top'[Top]), MIN('Top'[Top]))Also update the previous measurecomp_name Included = IF([Rank By Amount] <= [Selected Top N Value New],1,0)
- Mariusz
Community Champion
Hi Anonymous
To show a slicer with top N, you need to create a Rank Measure like the example below.
Rank Brand = RANKX( CALCULATETABLE( VALUES( 'Product'[Brand] ), ALLSELECTED() ), CALCULATE( SUMX(Sales, Sales[Net Price] * Sales[Quantity]) ),, DESC )and use it as a Visual filter as below
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.- AnonymousNot applicable
Hi
Thanks for your help.
In this case if i use visual filter for the slicer and restict it by setting the "is less than or equal to" = 15,
then the slicer does not allow me to go more than rank 15 , i have upto 200 rank, which the user will also want to see.
Just deafulting it to the top 15 in the table visual. Please suggest how to achive that.
Thanks
- Mariusz
Community Champion
Hi Anonymous
Can you share some data sample and explain your scenario based on that.
Best Regards,
Mariusz
If this post helps, then please consider Accepting it as the solution.