Reply
Frequent Visitor
Posts: 3
Registered: ‎04-20-2017
Accepted Solution

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


Accepted Solutions
Moderator
Posts: 1,041
Registered: ‎03-06-2016

Re: RANKX Help

@andrewa712,

 

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

Capture.PNGCapture1.PNG

 

View solution in original post


All Replies
New Contributor
Posts: 570
Registered: ‎09-19-2016

Re: RANKX Help

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

Moderator
Posts: 1,041
Registered: ‎03-06-2016

Re: RANKX Help

@andrewa712,

 

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

Capture.PNGCapture1.PNG