Forum Discussion

andrewa712's avatar
andrewa712
New Member
9 years ago
Solved

RANKX Help

Hello,

 

I have data sents for a Category, Date, and a Number field. What I want to do is make a Measure to Rank the categories based on the date slicers chosen on the display.  Basically what I need is:

 

Category     Value     Rank

 

And the columns for Value and Rank adjust as I select Days, Months, Years, Etc. So the default view is sum of everything, but then I want to see the ranks for the month of April in 2016, and it shows the totals and the rank of the adjusted totals for that month.

 

So far everything I tried just gives me 1s for everyone's Rank or I get an error.

 

Thank you

  • andrewa712,

     

    Please use the measure below.
    SumValue = SUM(Table1[Value])
    Rank = IF(
                HASONEVALUE(Table1[Month])
          ,RANKX(ALLEXCEPT(Table1,Table1[Month]),Table1[SumValue])
          )

     

2 Replies

  • Hi andrewa712,

     

    Your rank measure should look something like this:

     

    Rank = RANKX(ALLSELECTED(Table[Category]),CALCULATE(sum(Table[Value])))

    Doing this you will have a rank based on the selected values from table (slicer of date) and the sum of the value.

     

    Please be aware if you place any other field in your table than the Category for making the aggregations your rank will be always 1.

     

    Regards,

     

    MFelix

  • v-caliao-msft's avatar
    v-caliao-msft
    Microsoft Employee

    andrewa712,

     

    Please use the measure below.
    SumValue = SUM(Table1[Value])
    Rank = IF(
                HASONEVALUE(Table1[Month])
          ,RANKX(ALLEXCEPT(Table1,Table1[Month]),Table1[SumValue])
          )