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
CalebR
Resolver I
Resolver I

RankX Ranking Ties

Hello,

Can someone help with how to break ties? I have the below dax forumla creating a ranking column in my table using item code that thens ranks by the earliest date. I tried adding dense to the ties portion of the formula and I get this error

CalebR_0-1674838017017.png

 

Ranking =
VAR __cd = PO_PurchaseOrderDetail[ItemCode]
RETURN
    RANKX( FILTER( PO_PurchaseOrderDetail,  PO_PurchaseOrderDetail[ItemCode] = __cd ),PO_PurchaseOrderDetail[PODATE])

Ranking error using Dense: 
Rtotal =
VAR __po = PO_PurchaseOrderDetail[PurchaseOrderNo]
VAR __cd = PO_PurchaseOrderDetail[ItemCode]
RETURN
    RANKX( FILTER( PO_PurchaseOrderDetail,  PO_PurchaseOrderDetail[ItemCode] = __cd ),PO_PurchaseOrderDetail[PODATE], DENSE)
 

Results: 
CalebR_1-1674838216596.png

 

Expected Ressult:
CalebR_0-1674838186076.png

 

Thanks so much in advance! 


1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @CalebR 

Syntax error. You need to have thee commas before "Dense" not only one. However, this won't help to break the ties. There must be other columns that can be used to break the tie but simplist method is to create an index column using power query then your ranking formula would be

Rtotal =
RANKX (
CALCULATETABLE (
PO_PurchaseOrderDetail,
ALLEXCEPT ( PO_PurchaseOrderDetail, PO_PurchaseOrderDetail[ItemCode] )
),
PO_PurchaseOrderDetail[Index],
,
asc,
DENSE
)

 

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @CalebR 

Syntax error. You need to have thee commas before "Dense" not only one. However, this won't help to break the ties. There must be other columns that can be used to break the tie but simplist method is to create an index column using power query then your ranking formula would be

Rtotal =
RANKX (
CALCULATETABLE (
PO_PurchaseOrderDetail,
ALLEXCEPT ( PO_PurchaseOrderDetail, PO_PurchaseOrderDetail[ItemCode] )
),
PO_PurchaseOrderDetail[Index],
,
asc,
DENSE
)

 

Thank you! This worked perfectly, I guess I just wasnt considering how the order entry table would already be in order by date since when a new one is entered its always the most recent entry. 

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.

Top Solution Authors