Conditional Rank, the easy way [quick tip]
Yesterday, my mate from across the ditch, Hui posted about conditional rank formula (RANKIFS) using awesome SUMPRODUCT.
Of course, not everyone can whip up a sumproduct formula like that. On a scale of One to Hui of Excel awesomeness, you would need to be at least an H to write sumproduct or countifs formulas shown in that post. So does it mean, you can’t conditional rank if you don’t know your X from L?
Don’t worry. We got you covered. You can still get your conditional ranks, without inception level array formulas. Simple, use pivot tables instead.
Two level (or multilevel ranking) with Pivot Tables
Let’s say you have data like this and you want to know what the department level rank of each student.
The process for creating these ranks is ridiculously simple. Just,
 Insert a pivot table from your data
 Add level and detail fields to row labels area (in this case, we shall add Department and Student to row labels area)
 Add field on which you want to rank to values area (ie Score)
 Right click on value field and go to “Show values as” > “Rank…”
 Set up base field as the lower level (ie Student in our case)
 Bingo, your ranking problem is sorted.
Here is a quick demo of how to use ranking feature in Pivot Tables.
Download Example Workbook:
Click here to download workbook with the few pivot table ranking scenarios. Check it out to learn more.
Do you use pivot tables for ranking?
I use them all the time for such complex, filter driven ranking in my reports. While we could use formulas to get similar results, I think Pivots shine when it comes to ranking, as they naturally resolve ties (without complex deduplication logic) and give results in short time. The only problem is we need to refresh them whenever there is a change in data. But it is a small price to pay for avoiding complex formulas.
What do you think? Do you use pivot tables for ranking your data? Share your stories in the comments section.
Also, check out our Pivot Table Central for all things pivot, right from basics to ninjalevel stuff.
 

Leave a Reply
Formula Forensics 043: Rankifs or Conditional Rank  Which power plan is best for me? Excel for everyday problems 
8 Responses to “Conditional Rank, the easy way [quick tip]”
Another, equally easy, way is to use a helper column to deal with the conditions, then use the standard RANK formula.
It's far less awesome than either a pivot table or a SUMPRODUCT / COUNTIFS formula, but it is easy, and everyone's sheet has room for an extra column or two....(or 16,000) 🙂
@Andy
The problem with helper Columns is that you need a Column for every Criteria Combination to segregate each Criteria
...or an IF(AND(...
I take your point, but my experience is usually that my customer only wants to see the data ranked one way at a time, sometimes being able to change the basis at will (eg Period / YTD).
Again  not claiming it's better!
Ha Ha
I actually hadn't even noticed Ian's Rank.
Must be another Ian as I would be in Engineering anyway.
Nice answer anyways Chandoo
I really should use Pivot Tables more shouldn't I?
Thanks Hui. Yes, they are powerful and simple, so I say Pivot whenever possible. 🙂
Neat solution! I tend to use RANKX in PowerPivot DAX to solve conditional rank.
But this is quick and easy solution for all to use. 🙂
And works across multiple versions of Excel (at least for more than PowerPivot).
I use RANKX as well for solving condition rank. I never knew this solution, Thanks 🙂