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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.