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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Dynamic Top N

Greetings,

 

I have seen several examples with a dynamic top N but I just can't seem to get it working in my report.

Could someone have a look at my example ?

 

 I have created below table  for selection -

 

alpha_123_0-1619456955516.png

Based on below chart I want to give top n selection.

alpha_123_1-1619457705147.png

In the place of Axisi kept Business process type and in the place of value I kept parameter, the measure i have created i.e. 

parameter = VAR X= SELECTEDVALUE(Slider_BP[Value])
VAR Y= CALCULATE(COUNT(Sheet1[Business_Process_Type]),Sheet1[Category]=1)
RETURN
Y

alpha_123_2-1619457784988.png

I know i am missingout something in my dax that y the slicer is not working.

Can anyone help me with this?

 

Thank you in advance!

 

 

 

 

1 ACCEPTED SOLUTION

@Anonymous , Assume you have measure on which you want rank 

 

measure =CALCULATE(COUNT(Sheet1[Business_Process_Type]),filter(Sheet1,Sheet1[Category]=1))

 

Rank you want 

 

rank = rankx(allselected(Sheet1[Business_Process_Type]) ,[measure] )

 

filter on Rank 
Rank Top N= CALCULATE(if([Rank]<=SELECTEDVALUE(Slider_BP[Value]),[measure],BLANK()) ,VALUES(sheet1[Business_Process_Type]))

 

using TOPN 

Top N = CALCULATE([measure],TOPN(10,all(sheet1[Business_Process_Type]),[measure],DESC),VALUES(sheet1[Business_Process_Type]))

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

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

@amitchandak , tried but did not work.

@Anonymous , change this statement and try

CALCULATE(COUNT(Sheet1[Business_Process_Type]),filter(Sheet1,Sheet1[Category]=1))

 

if not share your TOPN code

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
Anonymous
Not applicable

@amitchandak, I tried to write below formula as per the post that you referred. Could you please rectify my dax?

alpha_123_0-1619458949010.png

 

@Anonymous , I think the Rank is not used correctly.

Can you paste the formula in text format

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns

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
Anonymous
Not applicable

@amitchandak , Here you go-
parameter = VAR X= SELECTEDVALUE(Slider_BP[Value])
RETURN
SWITCH(TRUE(),
X=1,COUNT(Sheet1[Business_Process_Type]),
RANKX(
ALLSELECTED(Sheet1[Business_Process_Type]),
CALCULATE(COUNT(Sheet1[Business_Process_Type]),Sheet1[Category]=1)
=>X
COUNT(Sheet1[Business_Process_Type])

@Anonymous , Assume you have measure on which you want rank 

 

measure =CALCULATE(COUNT(Sheet1[Business_Process_Type]),filter(Sheet1,Sheet1[Category]=1))

 

Rank you want 

 

rank = rankx(allselected(Sheet1[Business_Process_Type]) ,[measure] )

 

filter on Rank 
Rank Top N= CALCULATE(if([Rank]<=SELECTEDVALUE(Slider_BP[Value]),[measure],BLANK()) ,VALUES(sheet1[Business_Process_Type]))

 

using TOPN 

Top N = CALCULATE([measure],TOPN(10,all(sheet1[Business_Process_Type]),[measure],DESC),VALUES(sheet1[Business_Process_Type]))

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
Anonymous
Not applicable

@amitchandak Can we write in a single dax?

amitchandak
Super User
Super User

@Anonymous , refer to this blog

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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.