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

Can't make simple RANKX work

I'm trying to use RANKX in order to apply conditional formatting to have specific colors print for my Top 5 in a list. I can't for the life of me get my ranking to work correctly, but I have no doubt it's a simple one so I'm hoping someone can please help?

 

My dataset is huge and proprietary, so I'm going to just use a simple Excel example which serves the same purpose. Here is a base dataset: data1.PNG

 

 

At the most basic level, I simply need to add the values of Cat2 and rank them like this:

deata2.PNG

 

 

The dataset being ranked also needs to have all filters on the page applied before the ranking. So if I only select Cat1 = XX, this would be my result:

data3.PNG

 

I'm certain that is all a simple formula, but anything I try seems to give me all 1's for a rank, or something else which makes no sense. But the last thing I need, which I hope can be done, is to deal with ties by using another column (Cat2) to break the ties, as I can't have any ties if I'm going to use conditional formatting to pick 5 unique colors based on rank. So if I have a tie, I'd want to go to Cat2 alphabetically, like this:

data4.PNG

 

Thank you!

 

1 REPLY 1
MartynRamsden
Solution Sage
Solution Sage

Hi @Anonymous 

 

Try this:

Rank = 
RANKX(
    ALL( Table1[Cat2] ),
    CALCULATE( SUM( Table1[Value] ) )
)

 

There are some great blog posts about the use of RANKX.

Have a read of these:

 

Hope it helps.

 

Best regards,
Martyn


If I answered your question, please help others by accepting it as a solution.

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.