Why rankings deserve better than the Sort button
Sooner or later every report needs a ranking: the best sales reps of the quarter, the cheapest suppliers, the products with the most returns, the stores with the highest growth. The quick way is to click Data > Sort and read the order off the screen. That works once. The next day new figures arrive, the sort is out of date, and anyone who looks at the file has to know that it must be sorted again before it means anything.
A ranking built with formulas is different. It updates the moment a number changes, it can feed a top-5 list or a leaderboard chart, and it never depends on someone remembering to click a button. This lesson is for analysts, sales managers, team leads, teachers and anyone who builds league tables in Excel. You need only basic formulas; everything else is explained along the way.
The whole course uses classic functions that exist in every current desktop version of Excel since 2010: RANK.EQ, COUNTIF, COUNTIFS, LARGE, SMALL, INDEX and MATCH. Excel 365 has newer functions such as SORT, SORTBY and FILTER, and they are excellent, but many companies still run older versions, share files with partners who do, or need the logic behind a ranking to be visible step by step. The techniques here work everywhere, and they also make you understand what the new functions do for you.
Our example is Fernhill Outdoor Co., a fictional outdoor-gear wholesaler with twelve sales reps. The sales manager wants to rank them by Q3 sales. There is a catch that every real ranking has: some reps have exactly the same sales. How Excel treats those ties, and how you decide who comes first, is the subject of this lesson.
The core concept: a rank is a count
Before any function, here is the idea that makes every ranking formula easy to understand. A rep's rank is simply one plus the number of reps who did better. Finn sold 102,300 and nobody sold more, so his rank is 0 + 1 = 1. Ava sold 84,200; three reps (Finn, Chloe and Leo) sold more, so her rank is 3 + 1 = 4.
RANK.EQ(number, ref, [order]) does exactly this count for you. number is the value to rank, ref is the whole list, and the optional order decides the direction: leave it out (or use 0) and the largest value gets rank 1; use 1 and the smallest value gets rank 1. Sales, profit and scores are ranked largest first. Costs, returns, complaints and delivery times are usually ranked smallest first, because low is good.
Now the ties. Ava, Grace and Kira all sold 84,200. For each of them, exactly three reps did better, so all three get rank 4. The next rep, Isla with 77,050, has six reps above her and gets rank 7. Ranks 5 and 6 are skipped. This is called competition ranking (the way sports tables work: two runners sharing second place are followed by fourth place), and it is correct for a report. It becomes a problem only when another formula wants to look up "the rep with rank 5": there is none, so the lookup fails.
The solution is a unique rank, where every rep gets a different number from 1 to 12. You can build it in two ways. The first numbers ties in list order with a running count. The second, fairer one breaks ties by a second criterion, here the number of returns: among reps with equal sales, the one with fewer returns ranks higher.
Worked example: ranking Fernhill's twelve reps
The table below is the lab sheet with all four rank columns already calculated. Columns A to D are the data; E to H are what you build. All figures are example values for a fictional company.
| Rep (A) | Region (B) | Q3 sales (C) | Returns (D) | Rank (E) | Unique rank (F) | Returns rank (G) | Rank, tie-break (H) |
|---|---|---|---|---|---|---|---|
| Ava Morgan | North | 84,200 | 3 | 4 | 4 | 5 | 5 |
| Ben Ortiz | South | 71,500 | 5 | 8 | 8 | 10 | 9 |
| Chloe Park | East | 96,800 | 2 | 2 | 2 | 2 | 2 |
| Dan Whitaker | West | 71,500 | 2 | 8 | 9 | 2 | 8 |
| Ella Novak | North | 58,900 | 4 | 11 | 11 | 8 | 11 |
| Finn Galloway | South | 102,300 | 6 | 1 | 1 | 11 | 1 |
| Grace Liu | East | 84,200 | 1 | 4 | 5 | 1 | 4 |
| Hugo Brandt | West | 63,400 | 3 | 10 | 10 | 5 | 10 |
| Isla Romero | North | 77,050 | 2 | 7 | 7 | 2 | 7 |
| Jack Sutton | South | 49,800 | 7 | 12 | 12 | 12 | 12 |
| Kira Patel | East | 84,200 | 4 | 4 | 6 | 8 | 6 |
| Leo Fischer | West | 91,600 | 3 | 3 | 3 | 5 | 3 |
Column E is the plain RANK.EQ. Look at the three 84,200 rows (Ava, Grace, Kira): each shows 4. The two 71,500 rows (Ben and Dan) both show 8, and rank 9 is skipped. If you sum column E you get 74, not the 78 you would get from 1 + 2 + … + 12, because ties repeat numbers and skip others.
Column F is the unique rank: =RANK.EQ(C2,$C$2:$C$13)+COUNTIF($C$2:C2,C2)-1. The clever part is the range $C$2:C2. Its start is locked with dollar signs, its end is not, so when you copy the formula down, the range grows: in row 8 it is $C$2:C8, in row 12 $C$2:C12. The COUNTIF therefore counts how often this sales value has appeared so far. For Ava (the first 84,200) that is 1, so she keeps 4 + 1 − 1 = 4. For Grace it is 2, so she gets 5. For Kira it is 3, so she gets 6. Any value that appears only once gets + 1 − 1 = 0 added, so unique values keep their normal rank.
Column G ranks the returns in ascending order with =RANK.EQ(D2,$D$2:$D$13,1). Grace has 1 return, the fewest, and gets rank 1. Three reps share 2 returns and get rank 2. Again, ties are normal here.
Column H is the tie-break rank: =COUNTIF($C$2:$C$13,">"&C2)+COUNTIFS($C$2:$C$13,C2,$D$2:$D$13,"<"&D2)+1. Read it as a sentence: "count the reps with higher sales, add the reps with the same sales but fewer returns, add one". For Kira, 3 reps sold more, and 2 reps (Ava with 3 returns and Grace with 1) sold the same with fewer returns than her 4, so Kira gets 3 + 2 + 1 = 6. Grace has nobody tied with fewer returns and gets 3 + 0 + 1 = 4. The order inside the tie is now based on performance, not on who happens to be typed first.
| Cell | Formula (row 2, copied down) | Result for Grace (row 8) |
|---|---|---|
| E2 | =RANK.EQ(C2,$C$2:$C$13) | 4 (shared with Ava and Kira) |
| F2 | =RANK.EQ(C2,$C$2:$C$13)+COUNTIF($C$2:C2,C2)-1 | 5 (second 84,200 in the list) |
| G2 | =RANK.EQ(D2,$D$2:$D$13,1) | 1 (fewest returns) |
| H2 | =COUNTIF($C$2:$C$13,">"&C2)+COUNTIFS($C$2:$C$13,C2,$D$2:$D$13,"<"&D2)+1 | 4 (wins the tie with 1 return) |
In the chart the skipped ranks are easy to see: after the three peach bars at rank 4, the next label is rank 7. That is exactly the gap a later "find rank 5" lookup would fall into. The second diagram shows the two ways of closing it.
Which kind of rank do you need?
There is no single "correct" rank. The right one depends on what you do with it. The table compares the five common methods on Fernhill's two groups of tied values.
| Method | Ava, Grace, Kira (84,200) | Ben, Dan (71,500) | Next rep (Isla / Hugo) |
|---|---|---|---|
| RANK.EQ (competition rank) | 4, 4, 4 | 8, 8 | Isla 7, Hugo 10 |
| RANK.AVG (average rank) | 5, 5, 5 | 8.5, 8.5 | Isla 7, Hugo 10 |
| Unique rank, list order | 4, 5, 6 | 8, 9 | Isla 7, Hugo 10 |
| Unique rank, fewer returns first | Grace 4, Ava 5, Kira 6 | Dan 8, Ben 9 | Isla 7, Hugo 10 |
| Dense rank (no gaps) | 4, 4, 4 | 6, 6 | Isla 5, Hugo 7 |
- RANK.EQ is the standard for reports and league tables that people read. Shared places are honest and familiar.
- RANK.AVG gives tied values the average of the positions they occupy (4, 5 and 6 average to 5). It is common in statistics, for example in rank-based tests, and rarely used in business reports.
- Unique rank in list order is the workhorse for formulas: top-N lists, extracts and leaderboards need one row per rank. It is simple, but the order inside a tie is arbitrary.
- Unique rank with a tie-breaker is the best choice whenever a sensible second criterion exists: fewer returns, higher margin, earlier date, lower cost.
- Dense rank has no gaps: the next value after a tie gets the next number. One classic formula is
=SUMPRODUCT(($C$2:$C$13>C2)/COUNTIF($C$2:$C$13,$C$2:$C$13))+1. It is useful when you rank price levels or grades rather than people.
Step by step: build the rankings in Excel
You can do these steps in your own file or right now in the lab at the top of this page, where the Coach checks every formula.
- Enter the data in A1:D13: Rep, Region, Q3 sales and Returns, with the headers Rank, Unique rank, Returns rank and Rank (tie-break) in E1:H1.
- Click E2 and type
=RANK.EQ(C2,C2:C13). Before pressing Enter, click intoC2:C13in the formula and press F4 once to turn it into$C$2:$C$13. Press Enter. - Copy the formula down: select E2:E13 and press Ctrl+D, or double-click the fill handle at the bottom right of E2. Check that E8, E2 and E12 all show 4.
- In F2 type
=RANK.EQ(C2,$C$2:$C$13)+COUNTIF($C$2:C2,C2)-1. Lock only the start of the COUNTIF range:$C$2:C2. Copy down to F13. - Check the unique rank: in an empty cell type
=SUM(F2:F13). Twelve different ranks from 1 to 12 always sum to 78. If you get a different number, the range is not growing correctly. - In G2 type
=RANK.EQ(D2,$D$2:$D$13,1). The 1 at the end ranks ascending, so the fewest returns get rank 1. Copy down. - In H2 type
=COUNTIF($C$2:$C$13,">"&C2)+COUNTIFS($C$2:$C$13,C2,$D$2:$D$13,"<"&D2)+1and copy down to H13. The">"&C2part joins the operator with the value, which is how COUNTIF accepts comparisons with a cell. - Make ties visible: select A2:D13, go to Home > Conditional Formatting > New Rule > Use a formula to determine which cells to format, enter
=COUNTIF($C$2:$C$13,$C2)>1and choose a light fill. Every tied row is now highlighted. - To test that everything is dynamic, change Kira's sales from 84,200 to 84,300. Watch E, F and H update at once: Kira jumps to rank 4 and the remaining tie between Ava and Grace is resolved automatically.

Common mistakes and how to spot them
- Forgetting the dollar signs.
=RANK.EQ(C2,C2:C13)copied down becomesC13:C24in the last row, so the last rep is ranked against a list that contains only himself. Symptom: several reps near the bottom show rank 1. Fix:$C$2:$C$13. - Locking the running range completely.
COUNTIF($C$2:$C$13,C2)counts all ties, not the ones so far, so every tied rep gets the same higher number (Ava, Grace and Kira would all get 6). Symptom: the unique rank still has duplicates and=SUM(F2:F13)is not 78. - Wrong direction. Adding 1 as the third argument for sales makes the smallest seller rank 1. Symptom: your top performer shows rank 12. For returns, costs or errors, you usually do want the 1.
- Comparison without the ampersand.
COUNTIF($C$2:$C$13,">C2")compares with the text "C2", not with the value in C2, and returns 0. Write">"&C2. - Hidden decimals. Sales of 84,200.40 and 84,200 both display as 84,200 with a whole-number format but are not tied. Symptom: what looks like a tie gets different ranks. Spot it by increasing the decimals or rounding the source.
- Numbers stored as text. Figures imported from another system may be text. They are not counted in the ranking range and can make the formula return an error. Spot them by left alignment and the green triangle; convert with Data > Text to Columns > Finish.
- Empty cells. A rep without a figure can return #N/A because there is nothing to rank. Decide whether the rep should have 0 or be excluded, and wrap the formula in IF if needed.
Quick reference: functions and shortcuts used
| Function / shortcut | What it does | Example |
|---|---|---|
| RANK.EQ(number, ref, [order]) | Position of a number in a list; ties share the best rank. order 0 or omitted = largest is 1, order 1 = smallest is 1 | =RANK.EQ(C2,$C$2:$C$13) |
| RANK.AVG | Like RANK.EQ, but ties get the average of the positions they occupy | =RANK.AVG(C2,$C$2:$C$13) |
| RANK | Older name of RANK.EQ, kept for compatibility | =RANK(C2,$C$2:$C$13) |
| COUNTIF(range, criteria) | Counts cells that meet one condition | =COUNTIF($C$2:C2,C2) |
| COUNTIFS | Counts rows that meet several conditions at once | =COUNTIFS($C$2:$C$13,C2,$D$2:$D$13,"<"&D2) |
| ">"&C2 | Joins an operator with a cell value to build a criterion | =COUNTIF($C$2:$C$13,">"&C2) |
| F4 | Cycles a reference through $C$2, C$2, $C2 and C2 while editing a formula | Lock the rank range |
| Ctrl+D / fill handle | Copies the top formula down a selection | Select E2:E13, press Ctrl+D |
| Conditional Formatting | Highlights tied rows with a formula rule | =COUNTIF($C$2:$C$13,$C2)>1 |
Real-world uses of formula-based ranks
- Sales leaderboards. Rank reps or branches by revenue every month, break ties by margin or by fewer returns, and feed the unique rank into a top-10 list for the team meeting.
- Supplier scorecards. Rank suppliers by price ascending, then by delivery reliability as the tie-breaker. The ranking updates as soon as a new quote is entered.
- Product reviews. Rank products by units sold or by return rate to find the stars and the problem items, and keep the ranking live as the sales data is refreshed.
- Grades and assessments. Teachers and trainers rank results, use RANK.EQ for the published list and a tie-breaker (for example, the score of the final exam) where a strict order is required.
- Store and project KPIs. Rank locations by growth or projects by cost overrun, and highlight the bottom three for follow-up.
What you will build in the rest of this course
A unique rank is the key that unlocks every formula-based list. The next 19 lessons use it again and again, each with a practical lab on Fernhill's data.
A Top-5 List with LARGE + INDEX/MATCH (and Why Ties Break It). You build a self-updating top-5 list: LARGE finds the k-th highest value, INDEX/MATCH the rep. Then you see the duplicate-name bug that ties cause and fix it with today's unique rank.
Bottom-N with SMALL: Slow Sellers, Ties and Skipping Zeros. The mirror image: the five slowest products, an ascending unique rank, and a clean way to leave out new products that have not sold yet.
Extract Matching Rows: a k-th Match Helper with a Running COUNTIF. You build a "filter" with formulas: a helper column numbers the matching orders 1, 2, 3, INDEX/MATCH pulls them into a report block, and IFERROR keeps empty rows blank.
Multi-Criteria Extracts: AND Conditions, a Match Count and a Control Total. You extract open orders above a minimum amount, show how many there are with COUNTIFS and prove with a SUMIFS control total that nothing was lost.
Distinct Lists: First-Occurrence Flags, a Running Count and Totals per Customer. From an order log with repeated customers you build a list of distinct customers with a total for each, without Remove Duplicates.
Sorting Text with Formulas: COUNTIF "<" Ranks and a Two-Key Sort. You sort names A to Z with a COUNTIF rank and then sort by category and product at the same time, all with formulas.
Mid-course project: A Dynamic Top-N Leaderboard with a Bar Chart. Everything comes together in a leaderboard whose length you set in one cell, with names pulled by rank and a bar chart of the top five that updates by itself.
Summary
A rank is one plus the number of values that are better. RANK.EQ does that count, gives ties the same rank and skips the following numbers. For formulas that need one row per rank, add COUNTIF($C$2:C2,C2)-1 to number ties in list order, or use COUNTIF(…,">"&C2)+COUNTIFS(…,C2,…,"<"&D2)+1 to break ties by a second criterion. Lock your ranges with F4, check unique ranks with a sum of 78 for twelve rows, and highlight ties with conditional formatting.
Now try it yourself in the lab above: rank Fernhill's twelve reps, build the unique rank and the tie-break rank, and let the Coach check each formula. It takes about a quarter of an hour, and it is free.
Frequently asked questions
How does RANK.EQ handle ties in Excel?
Tied values get the same, best rank, and the following ranks are skipped. Three values tied at rank 4 are followed by rank 7.
How do I rank in Excel without duplicate ranks?
Add a running COUNTIF to the rank: =RANK.EQ(C2,$C$2:$C$13)+COUNTIF($C$2:C2,C2)-1. The growing range numbers tied values in the order they appear.
What is the difference between RANK.EQ and RANK.AVG?
RANK.EQ gives all tied values the top rank of their group, for example 4, 4, 4. RANK.AVG gives them the average of the positions they occupy, for example 5, 5, 5.
How do I rank from smallest to largest in Excel?
Use 1 as the third argument, for example =RANK.EQ(D2,$D$2:$D$13,1). The smallest value then gets rank 1, which suits costs, returns or delivery times.
How do I break a tie in Excel ranking with a second column?
Count the higher values and add the tied values that are better on the second criterion: =COUNTIF($C$2:$C$13,">"&C2)+COUNTIFS($C$2:$C$13,C2,$D$2:$D$13,"<"&D2)+1. Here fewer returns win the tie.
Why is my RANK formula wrong after copying it down?
The list reference was probably not locked, so it shifted with every row. Use absolute references such as $C$2:$C$13, which you can set with F4.
Keep going: Sorting & Filtering with Formulas: Top-N Lists, Dynamic Rankings & Extracts (No FILTER Needed)
This free lab is lesson 1 of 20. Unlock the other 19 hands-on labs, the final exam and your certificate for a one-time CHF 9.90.
- A Top-5 List with LARGE + INDEX/MATCH (and Why Ties Break It)
- Bottom-N with SMALL: Slow Sellers, Ties and Skipping Zeros
- Extract Matching Rows: a k-th Match Helper with a Running COUNTIF
- Multi-Criteria Extracts: AND Conditions, a Match Count and a Control Total
- Distinct Lists: First-Occurrence Flags, a Running Count and Totals per Customer
- Sorting Text with Formulas: COUNTIF "<" Ranks and a Two-Key Sort
- Mid-course project: A Dynamic Top-N Leaderboard with a Bar Chart
- Ranks within Groups: COUNTIFS Ranks per Category and the Top Three of Each
- Top-N inside a Subset: a Conditional Helper Column with LARGE
- Pareto Lists: Sort by Formula, Cumulative Share and a Pareto Chart
- Custom Sort Orders: Urgent to Low, then by Due Date, with MATCH as the Sort Key
- Flexible Criteria: OR Conditions, "Contains" Searches and a Criteria List
- Date Filters: Orders Between Two Dates and the Latest Five, Newest First
- Sorted Summaries: Totals per Customer, Ranked Largest First, with a Column Chart
- Rank Movement: This Month vs Last Month, Climbers, Fallers and the Biggest Mover
- Ranking Messy Data: Blanks, Numbers Stored as Text and "n/a" Entries
- Paging Through Results: Page Size, Page Number and "Showing 5 to 8 of 10"
- Running Rankings: Best-So-Far, Rank to Date and New-Record Days with a Line Chart
- Final Project: An Interactive Category Report with a Top-N List, Share and Chart