How-to recipes · Analysis
How to rank numbers with ties in Excel
Rank scores or sales with RANK.EQ and RANK.AVG, break ties so every rank is unique, or create a dense rank (1, 2, 3 without gaps).
Ranking turns numbers into positions: who is first, second, third. It is used for sales leaderboards, exam results, supplier scorecards and league tables. The difficulty is ties. When two students both score 92, are they both first? Is the next student second or third? Different situations need different answers, and Excel can produce each of them. This recipe shows standard ranking, average ranks for ties, unique ranks with a tie-breaker, and dense ranks without gaps.
The example data
Six students and their scores in A1:B7. Ben and Eva are tied on 92, and Ana and Chloe are tied on 88.
Standard ranking with RANK.EQ
RANK.EQ gives tied values the same rank and leaves a gap after them, the way sports results usually work. In C2, copied down:
| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | Rank |
| 2 | Ana | 88 | 3 |
| 3 | Ben | 92 | |
| 4 | Chloe | 88 | |
| 5 | Dev | 75 | |
| 6 | Eva | 92 | |
| 7 | Femi | 81 |
Ana's 88 is beaten by two scores of 92, so she is 3rd. Chloe also gets 3; Femi is 5th, not 4th.
Result: 3
The third argument controls the direction: leave it out (or 0) to give rank 1 to the highest value; use 1 to give rank 1 to the lowest, which is what you want for race times or costs. Lock the range with $ before copying; otherwise it slides down and the ranks are wrong.
In Microsoft 365 you can rank the whole column at once. RANK.EQ accepts an array as its first argument:
| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | |
| 2 | Ana | 88 | 3 |
| 3 | Ben | 92 | 1 |
| 4 | Chloe | 88 | 3 |
| 5 | Dev | 75 | 6 |
| 6 | Eva | 92 | 1 |
| 7 | Femi | 81 | 5 |
One formula spills a rank for every student.
RANK without the suffix is the older name of RANK.EQ and gives identical results; it is kept for compatibility.
Average ranks with RANK.AVG
RANK.AVG gives tied values the average of the positions they occupy. Ben and Eva share places 1 and 2, so each gets 1.5; Ana and Chloe share places 3 and 4 and get 3.5. This is the convention used in statistics, for example in rank correlation tests. The syntax is the same: =RANK.AVG(B2,$B$2:$B$7).
Unique ranks: break the ties
Prize lists and seat assignments need every rank to be different. Add a COUNTIF that counts how many times the same score appeared above the current row:
| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | Rank |
| 2 | Ana | 88 | |
| 3 | Ben | 92 | |
| 4 | Chloe | 88 | 4 |
| 5 | Dev | 75 | |
| 6 | Eva | 92 | |
| 7 | Femi | 81 |
Chloe's 88 is the second 88 in the list, so she gets 3 + 1 = 4. Ana, higher in the list, keeps 3.
Result: 4
Copied down, the ranks become 3, 1, 4, 6, 2, 5: every number from 1 to 6 exactly once. Here the tie is broken by list order. To break it by something meaningful, such as the earlier submission or a second score, sort the list by that criterion first, or add the second criterion to the formula with COUNTIFS.
Dense rank: no gaps
A dense rank gives tied values the same rank but does not skip numbers afterwards: 92 is 1st, 88 is 2nd, 81 is 3rd, 75 is 4th. This is useful for grade bands and price tiers.
In Microsoft 365, rank each score within the sorted list of distinct scores using XMATCH:
| A | B | C | |
|---|---|---|---|
| 1 | Student | Score | |
| 2 | Ana | 88 | 2 |
| 3 | Ben | 92 | 1 |
| 4 | Chloe | 88 | 2 |
| 5 | Dev | 75 | 4 |
| 6 | Eva | 92 | 1 |
| 7 | Femi | 81 | 3 |
SORT(UNIQUE(...),,-1) gives {92;88;81;75}; XMATCH finds each score's position in that list.
In Excel 2016 and 2019, use this formula in C2 and copy down. It counts the distinct scores that are higher than the current one and adds 1:
=SUMPRODUCT(($B$2:$B$7>B2)/COUNTIF($B$2:$B$7,$B$2:$B$7))+1Pitfalls
- Blank cells and text in the range are ignored by RANK.EQ, but a blank in the first argument returns
#N/A. Wrap the formula:=IF(B2="","",RANK.EQ(B2,$B$2:$B$7)). - Hidden decimals. 88 and 88.004 display the same with no decimals but are not tied. Round the scores first if ties should be based on what people see.
- Ranking within groups, for example within each class, needs COUNTIFS:
=COUNTIFS($A$2:$A$7,A2,$B$2:$B$7,">"&B2)+1where column A holds the class. - Sorting the table does not break RANK formulas, but it does change the tie-break order of the COUNTIF version.