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

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

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
Fabric Data Days is here Carousel

Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

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.