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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Jos13
Helper III
Helper III

RANKX with ALL()

Hi Team,

I have 2 measures to rank categories and products based on sales.

 

Category_Rank_All_Column = RANKX(ALL(Categories[CategoryName]),[Total Sales],,DESC)
ProductRanking = RANKX(ALL(Products[ProductName]),[Total Sales],,DESC)
 
When I select categories from slicer, products(Table2) ranked correctly but categories(Table 1) not.
Rank.png
 
Can someone please tell me the reason for this ?
Thanks in advance
1 ACCEPTED SOLUTION

Hi @Jos13 ,

 

 

Have a look at this video to understand the difference between ALL() and ALLSELCTED() when used with RANKX.

 

 

https://www.youtube.com/watch?v=z2qzJVeYhTY

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@Jos13 ,

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
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

 

Try like

Category_Rank_All_Column = RANKX(ALLselected(Categories[CategoryName]),[Total Sales],,DESC)

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

Hi,

I had tried ALLSELECTED(). I just wanted to know why ALL() function gives different results.

 

Thanks,

Jos

Hi @Jos13 ,

 

 

Have a look at this video to understand the difference between ALL() and ALLSELCTED() when used with RANKX.

 

 

https://www.youtube.com/watch?v=z2qzJVeYhTY

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

ALL removes filter from all the columns, or a table, on the other hand ALLSELECTED only takes in account any filter that is active outside of the given visual. in easier words whatever is at the grand total is what ALLSELECTED returns.

@Jos13 , Not sure from whom this question.

 

But All means remove the filter of that particular column, take all values, All selected to take selected values

 

Refer these fore more details

https://www.sqlbi.com/articles/the-definitive-guide-to-allselected/

https://www.sqlbi.com/articles/managing-all-functions-in-dax-all-allselected-allnoblankrow-allexcept...

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
Ashish_Mathur
Super User
Super User

Hi,

Does this work?

=Category_Rank_All_Column = RANKX(ALLSELECTED(Categories[CategoryName]),[Total Sales],,DESC)


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors