Forum Discussion

shaunwilks's avatar
shaunwilks
Icon for Helper V rankHelper V
8 years ago
Solved

RANKX Rank specific measure value in table

 

Hello All,

 

Any help would be greatly appreciated. 

Example table...

 Table1

Code             Date                          Sales$

AA                 12/10/2018               200.00

BB                 11/10/2018               200.00

AA                 10/10/2018               200.00

CC                 12/10/2018               200.00

DD                 14/10/2018              200.00

FF                 15/10/2018               200.00

FF                 17/10/2018               200.00

AA                 18/10/2018              200.00

 

I want to create a specifc ,measure to return me the rank of the string AA amongst the above sales.

I dont wish to have a table to collate totals for other reason.

The idea will be to have five seperate Measures that store the rank for AA BB CC DD FF.

These will be represented in cards on the report - I dont want to have to set Visual filters on each card.

 

is there a way in the RANKX statment where I can specify the text to rank.

 

ie What rank is Code "AA" in Table1.Code field for Sum(Sales$)

I have done rank statements before but they have always been for column names and been able to use for any code in the table.

In this example I wish to fix the Code and seek a rank for it.

 

Any suggestions welcome and help appreciated in advance.

  • HI shaunwilks

     

    Try this MEASURE pattern

     

    Measure =
    CALCULATE (
        RANKX ( ALL ( TableName[Code] ), CALCULATE ( SUM ( TableName[Sales$] ) ) ),
        TableName[Code] = "AA"
    )

2 Replies

  • Zubair_Muhammad's avatar
    Zubair_Muhammad
    Icon for Community Champion rankCommunity Champion

    HI shaunwilks

     

    Try this MEASURE pattern

     

    Measure =
    CALCULATE (
        RANKX ( ALL ( TableName[Code] ), CALCULATE ( SUM ( TableName[Sales$] ) ) ),
        TableName[Code] = "AA"
    )
    • shaunwilks's avatar
      shaunwilks
      Icon for Helper V rankHelper V

       

      Thanks very much - my production report was somewhat more complicated but the suggested formula you provided was a big help.

      I find myself comfortable with most DAX function but the RANKX one totally consfuses me.