Skip to content

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 in ref.
  • 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. 0 or left out ranks as if the list were sorted largest first, so the biggest value is 1. Any other number (normally 1) 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.

B3=RANK(A3,$A$2:$A$6,1)
ABC
1DataRANK (ascending)RANK.AVG (ascending)
2755
33.533.5
43.533.5
5111
6222
Microsoft's results: =RANK(A3,A2:A6,1) is 3 and =RANK(A2,A2:A6,1) is 5. Here the list is locked with $ so the formula can be copied down column B. Column C uses =RANK.AVG(A2,$A$2:$A$6,1): the tied 3.5s each get 3.5.

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.

C2=RANK.EQ(B2,$B$2:$B$7)
ABC
1RepSalesRank
2Ana$4,2002
3Ben$3,8504
4Cara$4,2002
5Dev$2,9006
6Eli$3,6005
7Fay$5,1001
Ana and Cara tie on $4,200, so both are 2nd and Ben is 4th. Nobody is 3rd.

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.

D4=RANK.EQ(B4,$B$2:$B$7)+COUNTIF($B$2:B4,B4)-1
ABCD
1RepSalesRankUnique rank
2Ana$4,20022
3Ben$3,85044
4Cara$4,20023
5Dev$2,90066
6Eli$3,60055
7Fay$5,10011
$B$2:B4 grows as the formula is copied down. In row 4 it finds $4,200 twice, so the rank goes up by 1. Whoever is higher in the list wins the tie.

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.

D2=COUNTIFS($B$2:$B$9,B2,$C$2:$C$9,">"&C2)+1
ABCD
1RepRegionSalesRegion rank
2GiaEast$3,1003
3HalWest$2,7503
4IvyEast$4,4001
5JonWest$3,9001
6KimEast$2,6004
7LeoWest$3,9001
8MiaEast$3,8002
9NedWest$1,9504
East is ranked only against East. In the West, Jon and Leo tie for 1st, so Hal is 3rd, the same skipping rule RANK.EQ uses.

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.

D2=SORTBY(A2:B7,B2:B7,-1)
ABCDE
1RepSalesRepSales
2Ana$4,200Fay$5,100
3Ben$3,850Ana$4,200
4Cara$4,200Cara$4,200
5Dev$2,900Ben$3,850
6Eli$3,600Eli$3,600
7Fay$5,100Dev$2,900
One formula in D2 fills D2:E7. It updates by itself when the sales change.

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

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.