Forum Discussion
Slicer with Top N
Hello!
I was wondering if there's a way to create a slicer that shows the Top N of a category. So you can for example have the top brands for Apples, Oranges and Blueberries in a slicer, and the slicer be Apple, Orange, and Blueberry. When you click on Apple then you'd be able to see a line graph with all the Top 5 apple brands in one chart and then cllick on Orange and see the same for orange.
Thank you!
Hi MichaelaMul
You can create a numeric range parameter table which column and automatically created measure can be used to filter a rank measure.
This measure ranks all distinct values in the Model column according to their sales. The ALL function is used applied to the Model column, ensuring that filters from other related columns remain effective.
Model Rank by Sales = RANKX ( ALL ( 'Product'[Model] ), [Total Sales],, DESC, DENSE )You can create another measure to returns just the sales of the models which ranks are <= the selected rank value.
Top N Model Sales = CALCULATE ( [Total Sales], FILTER ( VALUES ( 'Product'[Model] ), [Model Rank by Sales] <= [TopN Value] ) )Please see the attached pbix.
6 Replies
- lbendlin
Super User
yes, that is possible. What have you tried and where are you stuck?
- Ashish_Mathur
Super User
Hi,
Select Fruit in a slicer and in a table visual drag categories. Write this measure
Total = sum(sum(Data[units])
Measure = calculate([Total],top(3,all(Data[Category]),[Total]),values(Data[Category]))
Hope this helps.
- danextian
Super User
Hi MichaelaMul
You can create a numeric range parameter table which column and automatically created measure can be used to filter a rank measure.
This measure ranks all distinct values in the Model column according to their sales. The ALL function is used applied to the Model column, ensuring that filters from other related columns remain effective.
Model Rank by Sales = RANKX ( ALL ( 'Product'[Model] ), [Total Sales],, DESC, DENSE )You can create another measure to returns just the sales of the models which ranks are <= the selected rank value.
Top N Model Sales = CALCULATE ( [Total Sales], FILTER ( VALUES ( 'Product'[Model] ), [Model Rank by Sales] <= [TopN Value] ) )Please see the attached pbix.
- AnonymousNot applicable
Hi MichaelaMul,
Thanks danextian and Ashish_Mathur for Addressing the issue.
we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.Regards,
Vinay Pabbu- AnonymousNot applicable
Hi @MichaelaMul,
we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.Regards,
Vinay Pabbu- AnonymousNot applicable
Hi @MichaelaMul,
we would like to follow up to see if the solution provided by the super user resolved your issue. Please let us know if you need any further assistance.
If our super user response resolved your issue, please mark it as "Accept as solution" and click "Yes" if you found it helpful.Regards,
Vinay Pabbu