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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
glsera
New Member

RAnkX formula giving different values the same rank

Hi everyone,

 

I need help with a DAX formula. 

 

For some reason, my ranking doesn't seem to work. I need to create a rank without repeated values, I'm currently using the following formula:

RankCOPQ = RANKX(ALLSELECTED('Table');CALCULATE(SUM(('Table'[Amount $])));;DESC;Dense)

But, for some reasons, different values have the same rank, as you can see in the pic below:

PBi.png

How can I solve this out? I've been trying to find fixes everywhere but I wasn't able to find someone that had the same problem that I have.

 

Thank you very much!

 

 

 

 

3 REPLIES 3
Anonymous
Not applicable

RankCOPQ =
	RANKX(
		ALLSELECTED('Table'[Amount $]);
		CALCULATE(MAX('Table'[Amount $]))
		; ; DESC;
		Dense
	)

If you drop the "Amount $" column on a visual, only the distinct values from the column are displayed. If you use SUM(...) all the rows with the same value of "Amount $" will be summed up. This is not what you want. You want the value itself, hence MAX(...), which will return the value itself.

 

Best

Darek

Hi Darek,

 

Thank you very much. I appreciate the effort in helping me.

 

Thankfuly, the rank problem is solved, the thing is, the rank doesnt seem to work correctly, e.g.

pbi2.png

 

The rank 4 should be the number one, since it represents the biggest value in amount $, so, what I'm doing wrong?

 

I'm deeply sorry for the lack of knowledge, i'm a total beginner in DAX. 

Anonymous
Not applicable

You are simply not describing the problem correctly 🙂 My measure works correctly based on the assumptions I've made. But they are not what is true, hence the results.

 

You have to show the full report, not only the two columns as I suspect this is not what's in the visual. You don't rank the amounts themselves but something different. The amounts are most likely calculated for this "something different."

 

Please post the full story.

 

Best

Darek

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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