Home » excel » Ranking in Excel with multiple criteria

Ranking in Excel with multiple criteria

Posted by: admin March 9, 2020 Leave a comment

Questions:

For example, I need to create a merit list of few student based on total marks (column C), then higher marks in math (column B) –

A        B  C   D
-------------------------
Student1 80 220 1
Student2 88 180 3
Student3 90 180 2

Expected merit position is given in column D.

I can use RANK function but I can only do that for one column (total number). If total number of multiple student is equal, I could not find any solution of this.

How to&Answers:

You can try this one in D1

=COUNTIF($C$1:$C$99,">"&C1)+1+SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))

and then copy/fill down.
let me know if this helps.

Explanation

Your first criteria sits in column C, and the second criteria sits in Column B.
Basically, first it is counting the number of entries ($C$1:$C$99) that are bigger than the entry itself ($C1). For the first one in the ranking, you will get zero, therefore you need to add 1 to each result (+1).
Until here, you will get duplicate rankings if you have the same value twice.
Therefore you need to add another argument to do some extra calculations based on the second criteria:
To resolve the tie situation, you need to sumproduct two array formulas and add the result to the previous argument, the goal is to find the number of entries that are equal to this entry with $C$1:$C$99=C1 and have a bigger value in the second criteria column $B$1:$B$99>B1:

you add to convert TRUE and FALSE to 0s and 1s so that you can multiply them:
SUMPRODUCT(--($C$1:$C$99=C1),--($B$1:$B$99>B1))

the first array is to see how many ties you have in the first criteria. And the second array is to find the number of bigger values than the entry itself.

Note you can add as many entries as you like to your columns, but remember to update the ranges in the formula, currently it is set to 99, you can extend it to as many rows as you want.

Answer:

Sometimes a helper column will provide a quick and calculation-efficient solution. Adding the math marks to the total marks as a decimal should produce a number that will rank according to your criteria. In an unused column to the right, use this formula in row 2,

=C2+B2/1000

Fill down as necessary. You can now use a conventional RANK function on this helper column like =RANK(D2, D$2:D$9) for your ranking ordinals.

Answer:

Very simple (or, at least, much more simpler that the one provided by the best answer) ‘math’ solution: do a linear combination with weights.
Do something like

weighted_marks = 10*colC + colB

then sort weighted marks using simple rank function.

It does solve your problem, bulding the ranking you need.

Answer:

If you don’t like to limit the number of rows or the numbers used in the criteria, Jeeped’s approach can be extended. You can use the following formulas in cells D2 to L2, assuming that there are three criteria, the first one in column A, the second one in column B, and the third one in column C:

=RANK($A2,$A:$A,1)
=RANK($B2,$B:$B,1)
=D2*2^27+E2
=RANK(F2,F:F,1)
=RANK($C2,$C:$C,1)
=G2*2^27+H2
=RANK(I2,I:I,1)
=J2*2^27-ROW()
=RANK(K2,K:K,0)

The formulas have to be copied down. The result is in column L. Ties are broken using the row number.

If you like to add a fourth criterion, you can do the following after having the formulas above in place:

  1. Add the new criterion between columns C and D.
  2. Insert three new columns between columns I and J.
  3. Copy columns G:I to the new columns J:L.
  4. Copy column G to column M, overwriting its content.
  5. Change the formula in column L to point to the new criterion.

The factor 2^27 used in the formulas balances the precision of 53 bits available in double-precision numbers. This is enough to cover the row limit of current versions of Excel.