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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

RankX in dax calculation

Hello All,

 

I have a table having data like below and my requirement is I need to show top 10 categories based on Count.

But its giving eveyrthing as taking same value as one rank .(value 5 as rank 3)

I used rank and filtered the data but not working.

 

Could any one please help

Data :

CategoryCount
Cat19
Cat27
Cat35
Cat45
Cat55
Cat65
Cat75
Cat85
Cat94
Cat94
Cat94
Cat94
cat103

 

 

Expected:

CategoryCount
Cat19
Cat27
Cat35
Cat45
Cat55
Cat65
Cat75
Cat85
Cat94
Cat94

 

 

 

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to show the top 10 data in your table. Right?

Here are the steps you can refer to :
(1)For your data have repeat data , and when you put data in the table visual , it will be deduplicated.

So we need to add an index column in Power Query Editor:

vyueyunzhmsft_0-1670290906884.png

(2)For your need , you want to use a measure to filter the table . RIght?

We need to create a measure like this:

Flag = 
var _topn = TOPN(10 , ALLSELECTED('Table'))
var _showindex = SELECTCOLUMNS(_topn,"index",[Index])
var _curindex = MAX('Table'[Index])
return
IF(_curindex in _showindex ,1,0)

(3)Then we need to put the field we need on the visual and we can meet your need:

vyueyunzhmsft_1-1670290979559.png

(4)For this we can also use "What-if" parameter as a sliver to replace the "10" in our measure.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

View solution in original post

2 REPLIES 2
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to show the top 10 data in your table. Right?

Here are the steps you can refer to :
(1)For your data have repeat data , and when you put data in the table visual , it will be deduplicated.

So we need to add an index column in Power Query Editor:

vyueyunzhmsft_0-1670290906884.png

(2)For your need , you want to use a measure to filter the table . RIght?

We need to create a measure like this:

Flag = 
var _topn = TOPN(10 , ALLSELECTED('Table'))
var _showindex = SELECTCOLUMNS(_topn,"index",[Index])
var _curindex = MAX('Table'[Index])
return
IF(_curindex in _showindex ,1,0)

(3)Then we need to put the field we need on the visual and we can meet your need:

vyueyunzhmsft_1-1670290979559.png

(4)For this we can also use "What-if" parameter as a sliver to replace the "10" in our measure.

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Greg_Deckler
Community Champion
Community Champion

@Anonymous You could create a Rank Column like below and filter for <= 10

Rank Column = RANKX('Table',[Count],,DESC)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.