formulastreak

Rank without skipping numbers after a tie (dense rank)

Updated · Checked on a live sheet · Excel and Google Sheets

The formula

=SUMPRODUCT((E$2:E$11>E2)/COUNTIF(E$2:E$11,E$2:E$11))+1 gives a dense rank: tied values share a rank and the next value gets the next number, with no gap. It counts how many different values are bigger than this one, then adds 1. Fill it down the column.

In general: =SUMPRODUCT((range>value)/COUNTIF(range,range))+1

Try it on a live sheet

Two people share the top salary; the next salary is ranked 2, not 3 · edit G2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultG2 = 5
ABCDEFG
1NameDeptStartedBornSalaryLevelDense rank
2Amara OseiSales15 Apr 20192 Aug 1990$58,00025
3Ben FischerSupport9 Jan 202321 Nov 1996$41,00018
4Lina ChenEngineering1 Sep 201614 Mar 1987$88,00041
5Diego AlvarezSales28 Jun 202130 Jun 1993$52,00026
6Eva NovakFinance12 Feb 20185 Dec 1985$74,00033
7Farid HaddadEngineering4 Mar 202419 Jan 1998$68,00024
8Grace KimSupport19 Oct 202027 Sep 1991$45,00027
9Hugo MartinFinance11 May 20158 Apr 1979$88,00041
10Ines VargaEngineering14 Nov 202228 Feb 1995$79,00032
11Kenji MoriSales25 Aug 202516 Jul 2000$39,00019

Lina Chen and Hugo Martin both earn $88,000, so G4 and G9 both show 1. Ines Varga's $79,000 is the next salary, and G10 shows 2. RANK.EQ would have given her 3.

Why it works

Works out the result of SUMPRODUCT (step 2) plus 1.

  1. 1. COUNTIF: Counts the cells in E$2:E$11 whose value is equal to E$2:E$11.
  2. 2. SUMPRODUCT: Adds up every value of (E$2:E$11 is greater than E2) divided by the result of step 1, working on whole ranges at once.
  3. 3. Put together: Puts it together: the result of step 2 plus 1.

The standard rank, for comparison

RANK.EQ(E2, E$2:E$11) ranks from the highest, gives ties the same rank and then skips: two people at 1 means the next is 3. That's the usual “competition” ranking, and what most leaderboards use.

=RANK.EQ(E2,E$2:E$11)

Dense rank from a sorted list (Excel 2021 and later)

With dynamic arrays, list each salary once from highest to lowest and find the position: XMATCH(E2, SORT(UNIQUE(E$2:E$11), , -1)). It reads more clearly, but needs Excel 2021 or later and isn't available in Google Sheets, which has no XMATCH.

=XMATCH(E2,SORT(UNIQUE(E$2:E$11),,-1))

When you need it

Dense ranks suit league tables and grading bands where “second place” should mean the second-best result, not the third person in the list. They're also handy for turning values into a small number of levels, for example the salary tiers in a pay review. For prize-style leaderboards, where two people tying for first means nobody is second, the standard RANK.EQ is the right choice. Decide which one your reader expects before you publish the numbers, and label the column.

In Google Sheets

The SUMPRODUCT and COUNTIF formula works in Google Sheets unchanged. RANK.EQ exists in Sheets too. The XMATCH variant doesn't, because Google's function list has no XMATCH.

Common mistakes

  • Forgetting the $ on the range, so each row ranks against a shifted list.

  • Using it on a range with blank cells: COUNTIF of a blank is 0, which makes the division fail. Use a range without blanks.

  • Expecting a dense rank from RANK.EQ: it always skips after ties.

Practise SUMPRODUCT on a live sheet

Lesson 44, Ranks, percentiles and bands (Unit 13, Statistics), has 5 graded exercises, checked instantly, with steps and hints when you're stuck. Pro