Forum Discussion

insandur's avatar
insandur
Helper II
1 year ago

Repeating Rank values in the RANX dax

Hi, 

i am using RANKX measure to create rank index to my [devitaion in pcs] measure which is using two tables to calculated dviation. Froma Actuals & Forecast table . this is the measure i am using

RANKX(ALLSELECTED(Actuals[Ex Works Date],Actuals[Location Desc],Actuals[Ship-To Location Desc],Actuals[LGC ID],Actuals[LGC Description],Actuals[Qty]),[LAG 1 FC Deviation in Pcs],,DESC).   But i get repeating rank values except for 1st rank value.

Actual monthSupplier locationShip-To LocationLGCPurchase FCActualsDeviation in PcsFC Acuuracy in %Root causeContra actionsRank
8/1/2024ac1ab12312040127120115080-856%NANA1
8/1/2024ac1ab231428809886555985-31%NANA2
7/1/2024ab1ab56305406054060NANANA2
7/1/2024ab1ab76505355553555NANANA2
9/1/2024aa1abg54577601071304937015%NANA2
7/1/2024ab1ab23104525045250NANANA2




How do i get unique rank values to my table.

 

5 Replies

  • insandur 

    When you use the RANKX function in DAX to create a ranking measure, repeating rank values can occur when there are ties in the values being ranked. In your case, it seems that the [LAG 1 FC Deviation in Pcs] measure is resulting in equal values for multiple rows, which leads to the same rank being assigned.

    To address the issue of repeating ranks, you can modify your RANKX measure to use a tiebreaker. A common approach is to add a secondary column to the ranking criteria that ensures uniqueness among the tied items.

  • insandur , Try using  DAX
    RANKX(
    ALLSELECTED(
    Actuals[Ex Works Date],
    Actuals[Location Desc],
    Actuals[Ship-To Location Desc],
    Actuals[LGC ID],
    Actuals[LGC Description],
    Actuals[Qty]
    ),
    [LAG 1 FC Deviation in Pcs] + Actuals[UniqueID] * 1e-10,
    ,
    DESC
    )

  • saud968's avatar
    saud968
    Memorable Member

    Try this

    Rank =
    RANKX(
    ALLSELECTED(
    Actuals[Ex Works Date],
    Actuals[Location Desc],
    Actuals[Ship-To Location Desc],
    Actuals[LGC ID],
    Actuals[LGC Description],
    Actuals[Qty]
    ),
    [LAG 1 FC Deviation in Pcs] +
    DIVIDE(
    Actuals[Qty],
    MAXX(ALLSELECTED(Actuals), Actuals[Qty]),
    0
    ),
    ,
    DESC
    )

    Best Regards
    Saud Ansari
    If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!


    • insandur's avatar
      insandur
      Helper II

      Thank You Saud,

       

      I tried above method, i get below error on this.

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi insandur ,

    Is it possible to provide .pbix files without sensitive data? It looks like your '[LAG 1 FC Deviation in Pcs]' returned a duplicate value, so the subsequent rank returned is 2.

     

    Best Regards,
    Wenbin Zhou