Excel Formula to Calculate Rank

Formulas & functions · Updated November 23, 2026

The simplest Excel formula to calculate rank is =RANK(B2, $B$2:$B$10), where B2 is the value you want to rank and $B$2:$B$10 is the list of numbers to rank against. This returns the position of B2 in descending order (largest gets rank 1). For ascending order (smallest gets rank 1), use =RANK(B2, $B$2:$B$10, 1).

How the RANK Function Works

RANK is a legacy function available in all Excel versions. It takes three arguments: number (the value to rank), ref (the array of numbers), and order (optional; 0 or omitted for descending, nonzero for ascending). The function returns a number from 1 to the count of values in the list. If the list contains duplicate values, they receive the same rank, and the next rank is skipped. For example, if two values tie for rank 2, the next rank is 4, not 3.

To use it, type =RANK( in a cell, then click the cell with the value, select the range of all values, and press Enter. Use absolute references (with $ signs) for the range if you plan to copy the formula down a column.

RANK.EQ vs RANK.AVG

Excel 2010 introduced two improved functions: RANK.EQ and RANK.AVG. They replace RANK, though RANK still works for compatibility. RANK.EQ behaves exactly like RANK: duplicates get the same rank, and subsequent ranks are skipped. RANK.AVG assigns the average rank to duplicates. For instance, if two values are tied for 2nd place, RANK.AVG gives both a rank of 2.5. Use RANK.AVG when you need a continuous ranking without gaps, such as for statistical analysis or when calculating percentile scores.

Syntax for both is identical: =RANK.EQ(number, ref, [order]) and =RANK.AVG(number, ref, [order]).

Ranking with a Condition (e.g., by Group)

Sometimes you need to rank within a category, such as ranking sales within each region. The RANK function alone cannot do this. Use the COUNTIFS function to create a conditional rank. For example, with regions in column A and sales in column B, and data in rows 2 to 20, the formula for row 2 is:

=COUNTIFS($A$2:$A$20, A2, $B$2:$B$20, ">"&B2) + 1

This counts how many rows in the same region have sales greater than the current row, then adds 1 to get the rank. Copy it down to rank each row within its group. For ascending order, change the comparison to “<“&B2.

Ranking Without Ties (Unique Ranks)

If you need a rank that breaks ties arbitrarily (e.g., 1, 2, 3, 4 even if two values are equal), combine RANK with COUNTIF. For data in B2:B10, use:

=RANK(B2, $B$2:$B$10) + COUNTIF($B$2:B2, B2) - 1

The COUNTIF part counts how many times the value in B2 appears from the start of the list up to the current row. This adds a small increment for each duplicate, so the first duplicate gets a slightly higher rank than the second. The result is a unique rank for every row. This is useful when you need a stable ordering for sorting or lookup purposes.

Ranking with a Dynamic Array Formula

If you are using Excel 365 or Excel 2021, you can use the SORT and SEQUENCE functions to create a dynamic ranking table. For example, to rank values in B2:B10 in descending order and display the sorted values with their ranks, enter this formula in a single cell:

=SORT(B2:B10, -1)

This spills the sorted list downward. To get the ranks, use =SEQUENCE(ROWS(B2:B10)) in the adjacent column. This approach updates automatically if you change the data, but it does not handle ties specially—it simply lists the values in order. For a dynamic rank column next to the original data, use =RANK(B2, $B$2:$B$10) as before; it works fine in dynamic arrays.

Common Errors and Pitfalls

One common mistake is forgetting to lock the range with absolute references. If you copy =RANK(B2, B2:B10) down, the range shifts to B3:B11, then B4:B12, and so on, producing incorrect ranks. Always use $B$2:$B$10 for the ref argument.

Another issue is ranking text or blank cells. RANK only works with numeric values. If the list contains text or blanks, the function returns a #VALUE! error. To handle blanks, you can use IF to check for non-numeric values, but it is simpler to ensure the data range contains only numbers.

Also note that RANK treats empty cells as 0, which can skew results. If you have blanks, consider using a formula that ignores them, such as =IF(B2="","",RANK(B2,$B$2:$B$10)).

Ranking in Google Sheets vs Excel

Google Sheets uses the same RANK, RANK.EQ, and RANK.AVG functions with identical syntax. The main difference is that Google Sheets automatically updates formulas and handles dynamic arrays differently. In Excel, you may need to press Ctrl+Shift+Enter for array formulas in older versions, but in modern Excel 365, dynamic arrays work automatically. In Google Sheets, the SORT function works similarly but uses a different syntax: =SORT(B2:B10, 1, FALSE) for descending order. The COUNTIFS approach for conditional ranking works the same in both.

Frequently Asked Questions

How do I rank in ascending order? Add a third argument of 1 to the RANK function: =RANK(B2, $B$2:$B$10, 1). This gives the smallest value a rank of 1.

Can I rank based on a percentage or percentile? Yes, use the PERCENTRANK.INC function to get a percentile (0 to 1) instead of a rank. For example, =PERCENTRANK.INC($B$2:$B$10, B2) returns the percentage of values less than or equal to B2.

What if I want to rank from highest to lowest but show the lowest as rank 1? That is ascending order, so use the order argument of 1. If you want the opposite (highest as rank 1), omit the argument or use 0.

Why does my RANK formula return #N/A? This can happen if the number argument is not found in the ref range. Check that the value exists in the range. Also, if the range includes non-numeric text, RANK may return an error; ensure all cells are numeric.

How do I rank without skipping numbers after ties? Use RANK.AVG instead of RANK.EQ. For example, =RANK.AVG(B2, $B$2:$B$10) gives tied values the same average rank, so if two are tied for 2nd, both get 2.5 and the next rank is 4.

Can I rank based on multiple columns (e.g., total sales, then product name)? Yes, you can create a helper column that combines criteria, then rank that. For instance, use =B2*1000 + C2 to give sales priority, then rank the helper column. Or use a more complex formula with COUNTIFS to compare multiple columns.

Related

Try it: the Formula Explainer: paste any formula and see each function and reference in plain English.

More in Formulas & functions

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.