Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

RANKX DENSE functionality

Dear all,

 

Every now and then I stumble along the rankx function. This is what I use. Fairly simple.

 

PRODUCTSCAN = COUNTROWS('MyDataTablev 1)

RANKING = RANKX(ALLSELECTED('MyDataTablev 1'[Product EAN],'MyDataTablev 1'[language]),[PRODUCTSCAN],,DESC,dense)
 
Through the visual filters I filter my target table visual by "language" and "ean" by is not empty. This works so far. But even though I use "dense" in the RANKX dax "RANKING" shows the same rank for products with the same amount of rows
 
ProductscanEANlanguageRank
23123de1
181234de2
1012345de3
10123456de3
 
Could you help on this?
  • Anonymous's avatar
    Anonymous
    5 years ago

    HI Anonymous ,

     

    You need to break the RANK TIES.

     

    https://docs.microsoft.com/en-us/dax/rankx-function-dax

     

    The functionality of dense is 

     

    Dense

    The next rank value, after a tie, is the next rank value. For example if five (5) values are tied with a rank of 11 then the next value will receive a rank of 12.

     

    You will need a rank breaker.

     

    Use RAND

    RANKING = RANKX(ALLSELECTED('MyDataTablev 1'[Product EAN],'MyDataTablev 1'[language]),[PRODUCTSCAN] + RAND(),,DESC,dense)

     

    else 

     

    RANKING = RANKX(FILTER(ALLSELECTED('MyDataTablev 1'[language] = MAX('MyDataTablev 1'[language])),[PRODUCTSCAN] ,,DESC,dense)

     

     

    Else please share some sample data and the expected output

     

    Regards,
    Harsh Nathani
    Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

5 Replies