Forum Discussion

ibuhary's avatar
ibuhary
Helper I
7 years ago
Solved

RANKX

Hello there,

I have a table with Store ID, Store Name and Sales.

I have created a measure to Rank the Store Names based on highest sales.

StoreRank = RANKX(ALLSELECTED(
'Table'[Store Name]),
CALCULATE(SUM('Table'[Sales])),,DESC)

When I use the Rank alone with Store Name it works, but the moment I add store ID in the table it returns all ranks to - 1

Can anyone help me solve this issue, please.

  • sokg's avatar
    sokg
    7 years ago

    Not in my test data. See pic below

     

10 Replies

  • sokg's avatar
    sokg
    Solution Supplier

    Why do you use ALLSELECTED instead of ALL???

    Why do you use 'Table'[Store Name] instead of just 'Table'???

     

    so try this

     

    StoreRank =
    RANKX ( ALL ( Table ), CALCULATE ( SUM ( 'Table'[Sales] ) ),, DESC )
    • ibuhary's avatar
      ibuhary
      Helper I

      In that case the ranks returned are all 1 for all the stores

      • sokg's avatar
        sokg
        Solution Supplier

        Not in my test data. See pic below