Forum Discussion

fenixen's avatar
fenixen
Icon for Advocate II rankAdvocate II
10 years ago
Solved

How to Rank a list based on 2 values? double rankX?

  Current formula is as follows:  Overall Rank= RANKX(all('EM2016 Participants');[Points])   This ranks all the participants by Sum([Points]), works like a charm..  BUT.. we want the RANK to be ...
  • OwenAuger's avatar
    10 years ago

    Hi there,

     

    A pattern I have used in this situation is:

     

    Final value to be ranked =

    Rank on Primary Measure (ascending)

    + Rank on Secondary Measure (ascending) / (Total Row Count + 1)

     

    The first term is the Primary Measure rank, and the second term is the Secondary Measure rank scaled to be between 0 and 1 so that it can break ties in the Primary Measure rank.

     

    In DAX, assuming you have two measures, [Primary Measure] and [Secondary Measure], to be ranked over all rows of Table:

    Final Rank =
    RANKX (
        ALL ( Table ),
        RANKX ( ALL ( Table ), [Primary Measure],, ASC )
            + DIVIDE (
                RANKX ( ALL ( Table ), [Secondary Measure],, ASC ),
                ( COUNTROWS ( ALL ( Table ) ) + 1 )
            )
    )

    Just replace with your table/measure names and it should work. 

    Let me know how that goes :)