Conditional Ranking in Excel – RankIF using SumProduct

September 4, 2009
By

I was hunting around for a RANKIF function yesterday so I could rank a load of hospitals in terms of their cost per procedure.

RankIF

Unfortunately RANKIF isn’t one of the available functions but I managed to achieve the same effect by utilising the SUMPRODUCT function.

I wrote a SUMPRODUCT tutorial some time ago indicating how the powerful function can act as a multi conditioned SUMIF formula but it seems it can also act as a multi conditioned RANKIF formula as well.

The formula I used to achieve the above ranking was:

=1+SUMPRODUCT(($B$2:$B$12=B2)*($C$2:$C$12>C2))

Copied down the column it will return the number of organisations for a given procedure which have costs higher than the selected row. Adding 1 to the result just ensures that the highest cost organisation starts with a rank of 1 rather than 0.

Related Posts with Thumbnails

Tags: ,

11 Responses to “ Conditional Ranking in Excel – RankIF using SumProduct ”

  1. laure on October 9, 2009 at 10:33 pm

    Thank you very much for this very useful function. Really great!!

  2. admin on January 28, 2010 at 2:12 pm

    I just repeated my own ranking technique and got loads of #VALUE errors which screwed me up for a while.

    If you are getting a #VALUE error with SUMPRODUCT it implies that your data in column C (the values to be summed) are not all numeric values.
    They may be text values that look like numbers or “” if you have a conditional formula in that column. In my case there turned out to be a spurious #VALUE error in column C.
    Problem solved.

  3. Mike on March 29, 2010 at 9:25 pm

    This was a total lifesaver! Thanks so much for posting!

  4. Blink on March 15, 2011 at 2:08 pm

    This is a great formula. However, I need to conditionally rank AND uniquely rank each row. Does anyone have any ideas on that?

  5. Ben Sowter on March 23, 2011 at 11:44 am

    Admittedly SUMPRODUCT is a powerful formula but in this case would it not be both easier and quicker for large datasets to do it this way?

    =1+COUNTIFS($B$2:$B$12,B2,$C$2:$C$12,”>”&C2)

    This also makes it very straightforward to involve more complex criteria.

  6. admin on March 23, 2011 at 11:52 pm

    I recently came across the SUMIFS function for applying a multiple criteria SUMIF. I don’t know why I’d never seen it before because it has proved to be a life saver. I imagine the COUNTIFS function must be similarly useful. I’ll check it out and post a blog about the two.
    Thanks

  7. Excel Fan on March 24, 2011 at 5:45 am

    You might not have noticed the “IFS” functions because they are new to excel 2007.

  8. Jordan on June 16, 2011 at 10:25 am

    The sumproduct formula is a great way to rank. However, are you able to add a tiebreak to the existing formula?

  9. Tim on July 29, 2011 at 11:03 am

    This is AWESOME! I spent ages trying to use an array in the rank function to no avail.

  10. Jared on January 4, 2012 at 7:11 pm

    I love SumProduct, but I have a data set that includes “N/A” in some cells so the SumProduct would not rank properly. Then I switched to Ben Sowter’s suggestion of using COUNTIFS and that worked perfectly! For a relatively novice Excel user, though they both perform roughly the same action, the logic of COUNTIFS is easier to understand.

  11. Admin on January 4, 2012 at 9:10 pm

    Yes you are right, the series of IFS functions such as COUNTIFS and SUMIFS have been a godsend. Really clear and easily understandable. I dont think they are available in excel versions prior to 2007 though.

Leave a Reply

flickr rss

IMG_3996DSC_1185-1

What I'm Doing...

Posting tweet...

Ads



Reading List