HomeGoogle DocsSpreadsheetFlexible Array Formula to Rank Without Duplicates in Google Sheets

Flexible Array Formula to Rank Without Duplicates in Google Sheets

Published on

If you use the RANK function in a range to find the rank of numbers, it returns duplicates if there is any number repeated. Then how to Rank without duplicates in Google Sheets?

Rank is not on my list of favorite functions in Google Sheets. I did some experiments with this function in my leisure and realized that there is no way to return unique ranks in an array.

In other words, Ranking without duplicates is not possible with the RANK function in Google Sheets. But I have made a custom formula to do this.

Please see the below table. In column B, I have the Rank function, and I have my custom formula in Column C . See how both these formulas treat the numbers and return the Rank.

Formula to Rank without Duplicates in Google Sheets

Since the number in cell A2 repeats twice (you can see that the number is the same in Cell A8), the Rank formula in column B returns the same rank in Cell B2 and B8.

But my custom formula in Column C intelligently returns Unique Ranks. What is that formula to Rank without duplicates in Google Sheets?

The Formula to Rank Without Duplicates in Google Sheets

First, see the RANK formula which I have used in Cell B2.

=ArrayFormula(rank(A2:A8,A2:A8))

Here is my formula in Cell C2 that returns the Rank without duplicates.

=ArrayFormula(if(len(A2:A),array_constrain(sort({row(A2:A)-1,sort({row(A2:A)-1,A2:A},2,false)},2,true),9^9,1),))

This formula has the following features. Please go through it if you want to use it in any column and any range.

1. The Rank without Duplicates formula checks the values in the range A2:A and expands the result up to the last non-empty cell.

If you don’t want that flexibility, that means, if you want the formula to work only up to a certain number of rows, you can remove the first part of the formula, i.e., up to the Array_Constrain, and remove the end part from the last comma.

For example, if you want to find the ranks of numbers in the range A2:A20 without duplicates, you can use the formula below.

=array_constrain(sort({row(A2:A20)-1,sort({row(A2:A20)-1,A2:A20},2,false)},2,true),9^9,1)

2. I have set the formula to work from Row 2. If your range is A5:A, then change the -1 with -4.

This time, I am skipping the formula explanation part. If you want to learn the functions involved in my formula, here are the links.

Main Formulas:

Array_Constrain, Sort, and Row.

Formulas to Restrict the Formula Expansion:

ArrayFormula, IF, and Len.

That’s all about the formula to Rank without duplicates in Google Sheets. Enjoy!

Update: You can find one more formula here – How to Rank without Ties in Google Sheets.

Related Reading: How to Find Rank of a Non-Existing Number in an Existing Data Range.

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

XLOOKUP in Excel: Working with Visible Rows in a Table

In Excel, the XLOOKUP function isn't inherently designed to exclusively work with visible rows;...

SUMPRODUCT Differences: Excel vs. Google Sheets

The core purpose of the SUMPRODUCT function remains consistent across both Excel and Google...

Sum Values by Month and Category in Excel

With the help of EOMONTH, UNIQUE, and SUMIFS functions in Excel, you can efficiently...

More like this

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

Analyzing Column A Between Non-Adjacent Values in Column B: Google Sheets

This tutorial addresses a common scenario encountered in Google Sheets: how to sum, average,...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.