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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Suman8877
Advocate I
Advocate I

dax is not working properly in rankx need help ?

Hi Everyone,

I am trying to rank my order code data by the Avg. Xyz using the below DAX Formula.  However when the I return the results I am seeing duplicate rank values (example below).  Any suggestion on how to eliminate this issue? 

Ranking = RANKX(

    ALLSELECTED(detail),

    CALCULATE(SUM(detail[avg_xyz])),

    ,DESC,Skip

)

1 ACCEPTED SOLUTION
rohit1991
Super User
Super User

Hi @Suman8877 

You’re seeing duplicate ranks because RANKX is giving the same rank when two values are equal. By default you used Skip, which leaves gaps. You have two options:

  • If equal values should share the same rank (no gaps): use DENSE instead of Skip.
Ranking =
RANKX (
   ALLSELECTED ( detail[OrderCode] ),
   CALCULATE ( SUM ( detail[avg_xyz] ) ),
   ,
   DESC,
   DENSE
)

 

  • If you want every row to have a unique rank: add a tie-breaker column (like OrderCode) so that even when Avg_XYZ is the same, the rank will still be different.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

View solution in original post

2 REPLIES 2
FarhanJeelani
Super User
Super User

HI @Suman8877 ,

The issue of duplicate rank values in RANKX typically happens because the ranking expression returns the same result for multiple items, causing ties.

Your current formula:

Ranking = RANKX(
ALLSELECTED(detail),
CALCULATE(SUM(detail[avg_xyz])),
,
DESC,
Skip
)
returns the same rank for items with identical sums, which is expected with the Skip option since it skips rank numbers for ties but doesn't differentiate tied values.

 

Use DENSE ranking instead of SKIP if you want consecutive ranking but still handle ties:

 

Ranking = RANKX(
ALLSELECTED(detail),
CALCULATE(SUM(detail[avg_xyz])),
,
DESC,
Dense
)

This won't create unique ranks but avoids gaps/skips in ranks.

 

Please mark this post as solution if it helps you. Appreciate Kudos.

 

rohit1991
Super User
Super User

Hi @Suman8877 

You’re seeing duplicate ranks because RANKX is giving the same rank when two values are equal. By default you used Skip, which leaves gaps. You have two options:

  • If equal values should share the same rank (no gaps): use DENSE instead of Skip.
Ranking =
RANKX (
   ALLSELECTED ( detail[OrderCode] ),
   CALCULATE ( SUM ( detail[avg_xyz] ) ),
   ,
   DESC,
   DENSE
)

 

  • If you want every row to have a unique rank: add a tie-breaker column (like OrderCode) so that even when Avg_XYZ is the same, the rank will still be different.


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

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.