Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
KMcCarthy9
Helper V
Helper V

Dynamic Selection with Dynamic Top N

I have the below image as a page in my report. Would it be possible have end users choose the a specific KPI (MTTR Days, RT Days, FT Days, etc) via a slicer and have them select the Top/Bottom N number via a slicer? This new logic would allow me to remove all the different buttons and utimately just have 2 slicers, one with the KPIs listed and one with the Top N (10, 20, 50, etc) - maybe a third for Bottom N if it can't be done in 1. 

Possible? 
Thanks!

KMcCarthy9_0-1636493449264.png

 

4 REPLIES 4
Anonymous
Not applicable

Hi @KMcCarthy9 ,

 

I have built data sample:

Eyelyn9_0-1636684709957.png

Assume:

FT = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Suppliers]))
RT = CALCULATE(AVERAGE('Table'[Value]),ALLEXCEPT('Table','Table'[Suppliers])) 
SDR = CALCULATE(MEDIAN('Table'[Value]),ALLEXCEPT('Table','Table'[Suppliers]))

Then please follow these steps:

 

1. Enter a Type table, the values are all of your measure names:

Eyelyn9_1-1636684802544.png

2. Create a measure to match the type name and measure like this:

Measure = SWITCH(MAX('Type'[Type]),"FT",[FT],"RT",[RT],"SDR",[SDR])

3. Add a what-if paremeter:

Eyelyn9_2-1636684914790.png

4. Create a flag measure for filter later:

Flag = 
var _min=MIN('TopN'[TopN])
var _max=MAX('TopN'[TopN])
var _rank=RANKX(ALL('Table'),CALCULATE ( [Measure] ),,DESC,Dense)
return IF(_rank>=_min && _rank<=_max,1,0)

5. Finally create a matrix visual as shown below:

Eyelyn9_3-1636685031467.png

 

Output:

Eyelyn9_4-1636685060333.png

Eyelyn9_5-1636685092118.png

 

 

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for this @Anonymous as it is very interesting! 

 

I can't quite get the TopN selector to work properly. 

 

Also, would it be possible to have the end user select one of the 'types' from a slicer and the Top N number and have the matrix still show all the data in the other type columns but only show the Top N of the 'type' that is selected. 

For example, the output for Top 3 for FT would look like this:

KMcCarthy9_0-1636747600404.png

 

I have attached a sample pbix file here: pbix file 

 

Thank you for your help!

 

KMcCarthy9
Helper V
Helper V

Hi @amitchandak, thank you for this. This gets me halfway there as I got it working for 1 of the KPIs.
I'm trying to figure out how to expand up on this and have the end user be able to choose the KPI (MTTR, RT, FT, etc) from a similar slicer, and also have a slicer to select the Top N, but have them all housed in 1 table visual like above. 

Somthing like this:

KMcCarthy9_0-1636569013078.png

 

amitchandak
Super User
Super User

@KMcCarthy9 , You can use what if for that

https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.