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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
dgdgdg122db
Helper II
Helper II

Rank negative number result not expected

I am trying to rank the customers based on the margins, however, I am facing issues with the ranking results, in particular, the unexpected ranks on negative numbers.

 

Rank Capture.PNG

Without using tie Dense, 

Rank_ = RANKX(ALL('Customer EMEA '[Customer]),[Total margin],,DESC)
giving me the ranking result 88364 on the first negative number, which is not correct because my total customers are only 2788. I think it is probably ranking the negative number on my entire customer base: around 88K customers in total.

I am wondering why it gave me such results? and how can I fix it? 

I am expecting the ranking for the first negative number -0.05  is 2735

 

Please help.

 

Measures that I used:

Total margin = SUM('Customer EMEA '[Sales Margin])
Rank_ = RANKX(ALL('Customer EMEA '[Customer]),[Total margin],,DESC)
Rank Dense = RANKX(ALL('Customer EMEA '[Customer]),[Total margin],,DESC,Dense)
 
1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @dgdgdg122db 

 

If RRANKX with Dense fixes the issue why not just use that?

Please see the RANKX function description that explains how the Dense below.

https://docs.microsoft.com/en-us/dax/rankx-function-dax

 

If you want to know why it accrues you will need to investigate your Model, 'Customer EMEA ' is probably a good start.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

View solution in original post

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @dgdgdg122db 

Based on your description, I created data to reproduce your scenario.

a1.png

 

Here is the Rankx function.

 

RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]])

 

 

The default value of last parameter 'ties' is 'Skip'. For 'Skip', the next rank value, after a tie, is the rank value of the tie plus the count of tied values. In my example, one(1) values are tied with a rank of 1 then the next value will receive a rank of 4(1+3).

Whle for 'Dense', the next rank value, after a tie, is the next rank value. In my example, one(1) values are tied with a rank of 1 then the next value will receive a rank of 2.

 

For further information, you may refer to the following link.

https://docs.microsoft.com/en-us/dax/rankx-function-dax

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Mariusz
Community Champion
Community Champion

Hi @dgdgdg122db 

 

If RRANKX with Dense fixes the issue why not just use that?

Please see the RANKX function description that explains how the Dense below.

https://docs.microsoft.com/en-us/dax/rankx-function-dax

 

If you want to know why it accrues you will need to investigate your Model, 'Customer EMEA ' is probably a good start.

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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