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 August 31st. Request your voucher.

Reply
bennum
Frequent Visitor

RANKX failing with particular value when selected, but works with all others

Hello,

 

I am using RANKX function to create a "heatmap" of sorts that conditionally formats the metric card based on its rank. 

 

Items ranked 1 would be green, items in the middle yellow, end red. All on a gradient.

 

I noticed one item which was below average was green. I put together a table, and it had it's rank (correctly) as 13th, which should have indicated a reddish color.

However, when I selected just that item, it's rank went to 1. This is the only dimension I found that this applied to. If I clicked any of the other Metric Card Names, it kept the correct rank.

ML_pbi.jpgrank1.jpgrank5.jpg

 

The formula I have is:
RANKX(
ALL(Table[Metric_Card_Names]),
calculate(sum(Table[events])),,DESC)


I'm super confused, as it seems to handle it fine in all circumstances except the way I need it.

3 REPLIES 3
FreemanZ
Super User
Super User

hi @bennum 

try like:

RANKX(
ALLSELECTED(Table[Metric_Card_Names]),
calculate(sum(Table[events])),,DESC)

The problem with allselected is that really messes with the second scenario where I'm trying to get it's rank within the group on a metric card. With all selected, as soon as I narrow it to the single item in the filter it would reduce the whole list to that item.

Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


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

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.