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
ramshoney1225
Helper V
Helper V

Ranking For few columns

Hi 


I have a sample below table, which i hav the data this way.

ProductnameSubcategoryrevenue
Coolershomecooler345
RefregiratorMini refregiration543
FulltotalTotal456
BikesBicycles887
CarsBattery vehicles667

 

Now i want to create two rank

1.) based on Revenue for Product category

2.) based on Revenue for subcategory

 

When i create a RANK for Product category, my condition is "Fulltotal" should not be included in the Rank which always need to come last

 

When i create a RANK for Subcategory, my condition is "Total" should not be included in the Rank which always need to come last

 

SO my out put should be like this , Even though Total is high it is coming as Last, How to write the DAX for the below

 

 

ProductnameSubcategoryrevenueRankProdRankSub
BikesBicycles88711
CarsBattery vehicles66722
RefregiratorMini refregiration54333
Coolershomecooler34544
TotalTotal45655

 

Thanks,

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@ramshoney1225 Try:

Column = 
    VAR __Count = COUNTROWS('Table5')
RETURN
    IF([Productname]="Fulltotal",__Count,RANKX(FILTER(ALL('Table5'),[Productname]<>"Fulltotal"),[revenue],,DESC))

Column = 
    VAR __Count = COUNTROWS('Table5')
RETURN
    IF([Subcategory]="Total",__Count,RANKX(FILTER(ALL('Table5'),[Subcategory]<>"Total"),[revenue],,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...
amitchandak
Super User
Super User

@ramshoney1225 , Try measures like, assume revenue is a measure

 

Product Rank =

rankx(allselected(Table[product name]), [revenue])

 

Sub category Rank=

rankx(allselected(Table[subCategory name]), [revenue])

 

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-3-of-3-the-finale

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.