How to Give Ranking in Excel: RANK, RANK.EQ & RANK.AVG
In this article
To give a ranking in Excel, use the RANK.EQ function: type =RANK.EQ(number, ref, [order]) where number is the value you want to rank, ref is the range of all values to compare against, and order is 0 or omitted for descending (largest = 1) or 1 for ascending (smallest = 1). For example, =RANK.EQ(B2, $B$2:$B$10, 0) gives the rank of B2 among B2:B10, with the highest value ranked 1. The older RANK function still works for compatibility, and RANK.AVG assigns the average rank to ties. This guide covers the exact steps, the tie-handling differences, and how to fix the usual errors.
What You'll Need
- Excel 2010 or later (RANK.EQ and RANK.AVG were introduced in Excel 2010; the legacy RANK works in all versions). The steps below apply to Excel for Microsoft 365, Excel 2019/2021, and Excel for the web. Menu labels can differ slightly by version and region.
- A column or row of numeric values to rank, with no blank cells inside the range (blanks are ignored by RANK but can confuse your range selection).
- A clear decision on whether rank 1 should mean the largest value (descending) or the smallest value (ascending).
Step-by-Step
- Lay out your data. Put the values you want to rank in a single column, for example B2:B10. Leave the header in B1. Do not include the header in the range you pass to the function, because text is ignored but it is cleaner to exclude it.
- Click the first empty cell beside your first value (for example C2) where the rank should appear.
- Type the formula. Enter
=RANK.EQ(B2,$B$2:$B$10,0). The first argument is the value to rank; the second is the full list of values; the third is 0 for descending (largest gets rank 1) or 1 for ascending (smallest gets rank 1). If you omit the third argument, Excel treats it as 0 (descending). - Lock the range with dollar signs. The
$B$2:$B$10reference must be absolute so that when you copy the formula down, every row still compares against the whole list. If you forget the dollar signs, the range shifts and later rows rank against the wrong set of values. - Press Enter. The rank appears in C2.
- Copy the formula down. Drag the fill handle from C2 to C10, or double-click the fill handle. Each row now shows its rank within the full range.
- Decide how ties should behave. RANK.EQ gives tied values the same (highest) rank and skips the next rank — two values tied for 1st both show 1, and the next value shows 3. If you want tied values to share the average of the ranks they would have occupied, use
=RANK.AVG(B2,$B$2:$B$10,0)instead. If you want unique ranks with no gaps, add a tie-breaker such as=RANK.EQ(B2,$B$2:$B$10,0)+COUNTIF($B$2:B2,B2)-1, which increments duplicates in the order they appear. - Check the direction. If rank 1 should be the smallest value (for example, fastest time or lowest price), change the third argument to 1:
=RANK.EQ(B2,$B$2:$B$10,1). - Format and verify. Widen column C if ranks show as
#####. Spot-check a few rows: the largest value in a descending ranking should show 1, and the smallest should show the count of numeric values in the range.
Common Mistakes
- Relative range instead of absolute. Using
B2:B10without dollar signs makes the range slide down as you copy, so lower rows rank against fewer values and produce wrong numbers. - Including the header or totals row in the range. Text is ignored by RANK, but a totals row is a number and will be ranked alongside the real data, shifting every rank.
- Mixing the order argument. Leaving out the third argument defaults to descending. If you expected 1 for the smallest value, you will see the opposite.
- Assuming ties get unique ranks. RANK.EQ and the legacy RANK both assign the same rank to duplicates and leave gaps. Use RANK.AVG or a COUNTIF tie-breaker if you need unique numbers.
- Ranking text or blank cells. RANK ignores text, logical values and empty cells in the range, so the top rank may not be 1 if the range contains non-numeric entries. Clean the data first.
- Using RANK in a file opened in an older Excel version. RANK.EQ and RANK.AVG are not recognised by Excel 2007 and earlier; the formula shows #NAME?. Use RANK if the file must open in very old versions.
Tips
- Use a named range (Formulas > Define Name) for the list you rank against; the formula becomes
=RANK.EQ(B2, Scores, 0)and is easier to audit. - To rank within groups (for example, rank within each department), use
=COUNTIFS($A$2:$A$10,A2,$B$2:$B$10,">"&B2)+1for a descending rank inside each group, where column A holds the group label. - To rank only visible rows after filtering, RANK still counts hidden rows. Use SUBTOTAL-based helper columns or AGGREGATE if filtered ranking matters.
- Convert the range to an Excel Table (Ctrl+T) and use structured references; the table automatically expands and the ranking range stays correct as rows are added.
- For a percentile-style position rather than a rank, PERCENTRANK.INC and PERCENTRANK.EXC are the built-in functions; they answer a different question from RANK.
Troubleshooting
- #N/A appears. The value being ranked is not found in the reference range, or the range is on another sheet and the reference is wrong. Confirm the cell is inside the range and that both are numbers, not text that looks like a number.
- #VALUE! appears. One of the arguments is the wrong type — for example, the order argument is text instead of 0 or 1.
- #NAME? appears. The function name is misspelled, or the file is open in a version that does not support RANK.EQ/RANK.AVG. Fall back to
RANK. - All ranks are 1 or identical. The range reference is a single cell, or the range was not locked and has collapsed. Check the dollar signs and that the range covers all rows.
- Ranks look shifted by one. A header row or totals row is inside the range. Shrink the range to the data rows only.
- Duplicates get unexpected numbers. This is normal for RANK.EQ. Switch to RANK.AVG for averaged ties or add the COUNTIF tie-breaker for unique ranks.
- Numbers stored as text. If values were pasted from another system, they may be text. Select the column, use Data > Text to Columns > Finish, or multiply by 1 in a helper column, then re-rank.
Frequently Asked Questions
What is the difference between RANK, RANK.EQ and RANK.AVG?
RANK is the legacy function kept for compatibility. RANK.EQ behaves identically: ties get the same highest rank and gaps appear. RANK.AVG gives tied values the average of the ranks they would have occupied, so ties share a fractional rank.
How do I rank in ascending order?
Set the third argument to 1: =RANK.EQ(B2,$B$2:$B$10,1). The smallest value then receives rank 1. Omitting the argument or using 0 ranks largest as 1.
How do I rank without gaps when there are duplicates?
Add a COUNTIF term: =RANK.EQ(B2,$B$2:$B$10,0)+COUNTIF($B$2:B2,B2)-1. The expanding COUNTIF range counts how many times the value has appeared so far and increments each duplicate, producing unique ranks in list order.
Can I rank within categories or groups?
Yes. Use COUNTIFS with the group column as one criterion and a greater-than test on the value column as the other, then add 1. This gives a descending rank inside each group without needing to sort the data.
Why does RANK ignore some cells?
RANK only considers numbers. Text, logical values and blank cells in the reference range are skipped, so the highest rank may not equal 1 if the range contains non-numeric entries. Clean or exclude those cells.
Does ranking work in Excel for the web and Excel for Mac?
Yes. RANK, RANK.EQ and RANK.AVG are available in Excel for the web and Excel for Mac, and the formula syntax is the same. Menu labels for inserting functions can differ slightly between the desktop and web versions.