Lesson 61 of 92 · Free Excel Course
Excel · Excel function reference
Excel RANK Function: Syntax, Examples and Common Errors
How the Excel RANK function works, RANK vs RANK.EQ vs RANK.AVG, ranking ties, ranking within a group and fixing #N/A. Free practice workbook.
The RANK function tells you where a number places in a list: 1st, 2nd, 3rd and so on. Give it a number and the range it belongs to, and it returns a whole number (its position if the list were sorted), without you having to sort anything. By default the biggest number is ranked 1. Excel actually has three versions. RANK works in Excel for Microsoft 365 (Windows and Mac), Excel for the web and Excel 2016 to 2024, but Microsoft lists it as a compatibility function that "may not be available in future versions". RANK.EQ gives exactly the same answers and is the one to use in new work. RANK.AVG treats ties differently. Both newer names arrived in Excel 2010 and work everywhere RANK does.
Syntax
=RANK(number, ref, [order])
=RANK.EQ(number, ref, [order])
=RANK.AVG(number, ref, [order])
All three take the same arguments:
- number (required): the value you want the rank of, usually a cell such as
B2. It must appear inref. - ref (required): the list of numbers to rank against, such as
$B$2:$B$7. Cells that aren't numbers (text, blanks, TRUE/FALSE) are ignored. Lock it with $ signs before you copy the formula down. - order (optional): how to rank.
0or left out ranks as if the list were sorted largest first, so the biggest value is 1. Any other number (normally1) ranks smallest first, so the smallest value is 1.
How ties work. RANK and RANK.EQ give equal numbers the same rank, and the ranks they "use up" are skipped: two values tied for 2nd mean nobody is 3rd. RANK.AVG gives tied values the average of the positions they share, so two values tied for 2nd both get 2.5.
Examples
1. Microsoft's example: ascending order and ties. This is the data from Microsoft's RANK page. With order set to 1, the smallest number (1) is ranked 1 and the largest (7) is ranked 5. The two 3.5s share rank 3, and nothing gets rank 4.
| A | B | C | |
|---|---|---|---|
| 1 | Data | RANK (ascending) | RANK.AVG (ascending) |
| 2 | 7 | 5 | 5 |
| 3 | 3.5 | 3 | 3.5 |
| 4 | 3.5 | 3 | 3.5 |
| 5 | 1 | 1 | 1 |
| 6 | 2 | 2 | 2 |
2. A sales leaderboard, biggest first. Leave order out so the top seller is 1, and lock the list with $ so every row ranks against the same six cells. Type the formula in C2 and drag the fill handle down to C7.
| A | B | C | |
|---|---|---|---|
| 1 | Rep | Sales | Rank |
| 2 | Ana | $4,200 | 2 |
| 3 | Ben | $3,850 | 4 |
| 4 | Cara | $4,200 | 2 |
| 5 | Dev | $2,900 | 6 |
| 6 | Eli | $3,600 | 5 |
| 7 | Fay | $5,100 | 1 |
For lists where smaller is better (lap times, prices, golf scores) add the 1: =RANK.EQ(B2,$B$2:$B$7,1). Here that would make Dev ranked 1.
3. Break ties so every rank is different. Add a running count of how many times the value has appeared so far. The first $4,200 keeps rank 2; the second one becomes 3.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Sales | Rank | Unique rank |
| 2 | Ana | $4,200 | 2 | 2 |
| 3 | Ben | $3,850 | 4 | 4 |
| 4 | Cara | $4,200 | 2 | 3 |
| 5 | Dev | $2,900 | 6 | 6 |
| 6 | Eli | $3,600 | 5 | 5 |
| 7 | Fay | $5,100 | 1 | 1 |
To decide ties by something fairer, such as fewer returns, sort the list by that column first.
4. Rank within each region with COUNTIFS. RANK.EQ can't skip rows from other groups, but COUNTIFS can count "people in the same region who sold more". Add 1 and you have the rank.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Rep | Region | Sales | Region rank |
| 2 | Gia | East | $3,100 | 3 |
| 3 | Hal | West | $2,750 | 3 |
| 4 | Ivy | East | $4,400 | 1 |
| 5 | Jon | West | $3,900 | 1 |
| 6 | Kim | East | $2,600 | 4 |
| 7 | Leo | West | $3,900 | 1 |
| 8 | Mia | East | $3,800 | 2 |
| 9 | Ned | West | $1,950 | 4 |
For smallest-first ranks inside a group, change ">" to "<".
5. A ranked list instead of rank numbers. If you really want the names in order, you don't need RANK at all. In Excel for Microsoft 365, Excel 2021 and later and Excel for the web, =SORTBY(A2:B7,B2:B7,-1) spills a copy of the table sorted by sales, largest first (-1 means descending). Tied rows normally stay in their original order.
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Rep | Sales | Rep | Sales | |
| 2 | Ana | $4,200 | Fay | $5,100 | |
| 3 | Ben | $3,850 | Ana | $4,200 | |
| 4 | Cara | $4,200 | Cara | $4,200 | |
| 5 | Dev | $2,900 | Ben | $3,850 | |
| 6 | Eli | $3,600 | Eli | $3,600 | |
| 7 | Fay | $5,100 | Dev | $2,900 |
For just the top few values, LARGE returns the 1st, 2nd or 3rd biggest number directly.
Common errors
#N/A. The number isn't in ref. Usual causes: you typed a value that isn't in the list (=RANK.EQ(4000,$B$2:$B$7) returns #N/A because nobody sold exactly $4,000); the range wasn't locked, so as you copied down it slid to B3:B8, B4:B9 and the top rows dropped out; or the number is a result such as 3.4999 that only displays as 3.5. Lock ref with $ (press F4 after selecting it), and round both the values and the number the same way.
Duplicate or strange ranks after copying. Same cause as above: a relative ref. If the bottom rows show 1 or ranks repeat oddly, check that the formula in the last row still points at $B$2:$B$7.
Ranks are upside down. You wanted the smallest time to be 1 but got the slowest. Add 1 as the third argument. Remember: 0 or nothing means largest first.
A rank number is missing (2, 2, 4). That's not a bug; it's how RANK.EQ handles ties. If you need ranks with no gaps (1, 2, 2, 3), use a "dense rank": =SUMPRODUCT(($B$2:$B$7>B2)/COUNTIF($B$2:$B$7,$B$2:$B$7))+1. It counts each different higher value once, so Ben becomes 3rd instead of 4th. For no ties at all, use example 3.
A value is ignored. Numbers stored as text (often from imports, with a green triangle in the corner) are skipped because ref ignores anything that isn't a number. Convert them to real numbers first and the ranks will update.
Related functions
- LARGE function: the k-th biggest value, for top-3 lists.
- SMALL function: the k-th smallest value.
- COUNTIF, SUMIF and AVERAGEIF: the counting behind tie-breaks and group ranks.
- Sort and filter: sort the list itself.
- Statistics in Excel: averages, spread, percentiles and correlation in one lesson.
Try it yourself
Open the practice workbook. The Practice sheet has a sales list with yellow cells for a plain rank, a smallest-first rank, a RANK.AVG rank, a tie-break, a dense rank and a rank within each region. Check your results against the Answers sheet, which has every formula working.
Frequently asked questions
What is the difference between RANK and RANK.EQ in Excel?
None in the result: both give tied numbers the same rank and skip the next rank. RANK is the older name, which Microsoft keeps for compatibility and says may not be available in future versions. RANK.EQ (and RANK.AVG) arrived in Excel 2010, so use RANK.EQ in new work.
How do I rank in Excel without skipping numbers after a tie?
RANK.EQ always skips (two people tied for 2nd push the next person to 4th). For a gap-free "dense" rank use =SUMPRODUCT(($B$2:$B$7>B2)/COUNTIF($B$2:$B$7,$B$2:$B$7))+1 and copy it down. To give every row a different rank instead, use =RANK.EQ(B2,$B$2:$B$7)+COUNTIF($B$2:B2,B2)-1.
How do I rank from lowest to highest, so the smallest number is 1?
Put 1 (or any number that isn't 0) in the third argument: =RANK.EQ(B2,$B$2:$B$7,1). Use this for race times, costs or golf scores. Leave the argument out (or use 0) when the biggest number should be 1.
How do I rank within a group, such as each region separately?
RANK.EQ can't filter, so count with COUNTIFS instead: =COUNTIFS($B$2:$B$9,B2,$C$2:$C$9,">"&C2)+1. It counts how many people in the same region sold more, then adds 1. Ties share a rank, just like RANK.EQ.
Why does my RANK formula return #N/A?
The number you're ranking isn't in the list. That happens when you type a value that isn't there, when the list range slid down because it wasn't locked with $ signs, or when the cell shows a rounded number that doesn't exactly match the list.