Forum Discussion
POWERBI RANKX doest not work for me
Helo everybody,
I have been fighting with the RANKX function. My data looks like this:
Name Member_ID Tickets Closed Tickets Worked Survey Score Date
John B 123456 35 20 88% 1/1/2017
John B 123456 12 10 98% 1/2/2017
ALice N 234567 22 15 95% 1/1/2017
ALice N 234567 14 23 75% 1/2/2017
What I am trying to achieve is to create four columns:
1) Ranking by CLosed TIckets
2) Ranking by TIckets Worked (Touches)
3) Ranking by Survey Score
4) Total Ranking (Smalles product of all rankings = Number 1)
I also have a date slicer so I can look at the these metrics by specific days. I have had a similar data set where I had for each record 1 row and it worked. For this report I am uploading an aggregate data set by Name, and date. I am not sure if this really has anything to do with this.
At this point, I have tired many different formulas and the main issue I was running into was that I got 1's for every single person meaning I ranking each person seperately. This was my original formula:
Name of my table is TEST:
ranking 6 = RANKX(ALLSELECTED(TEST[Member_ID]),CALCULATE(SUM(TEST[Closed Tickets])))
Then I did some research and I have found this:
MM Closed tickets = Sum(TEST[Closed Tickets])
Tickets Ranking = if(HASONEVALUE(TEST[Member_ID]),RANKX(ALLSELECTED('TEST'),[MM Closed Tickets]),BLANK())
I get a ranking order now but it is partially wrong. Also, when I select specific days, it is working correctly. When I select all days, the rankings are off.
I would really appreciate any advice or help on this one. Thank you.
Lukas
1 Reply
- LaurentCouartouSolution Supplier
The problem comes from the correlation between the columns Member_ID and Name. I assume you have the operator's name in your report table.
Taking your first expression as an example:
RANKX(ALLSELECTED(TEST[Member_ID]),CALCULATE(SUM(TEST[Closed Tickets])))
RANKX will calculate the number of closed tickets for the current filter context, and for each row in the table you passed as a first argument.
However, in both cases, the existing values of TEST[Name] will be added to your filter context. Since for a given name, there is only one Member_ID (in your data), the measure evaluated against each row of the scanned table will only yield a result for a single row.
Beware there is a correlation between Survey Score, Tickets Closed, Tickets Worked, and Member_ID too, so you probably do not want to have these as filters, when calculating your rankings.
In the end, I suggest the following expression:
RANKX( ALL( TEST[Member_ID] ) ,CALCULATE(SUM(TEST[Tickets Closed]) , ALLEXCEPT(TEST, TEST[Member_ID], TEST[Date] ) ) )