How to Highlight Largest 3 Values in Each Row in Google Sheets

Published on

Today let me introduce to you the use of Large function to highlight the largest 3 values in each row in Google Sheets.

A while back I explained to you the use of Max function to conditional format the max value in each row.

Here is the link, if you didn’t see that – How to Highlight Max Value in a Row in Google Sheets.

With Large, we can highlight the largest ‘n’ values in each row. I have just put 3 in the title instead of ‘n’ for the sake of explaining the highlighting rule.

Here is one example of the use of the Large function to return the largest 1, 2, 3…. values from a row.

ABCD
125453550

Here the formula =large(A1:D1,1) will return 50, and =large(A1:D1,2) will return 45.

Now see the syntax.

=large(data,n)

To get the 3rd largest value from row # 1 above, now you may know what changes you should make to the formula. If not, see that Large formula below.

=large(A1:D1,3)

As per the title, what we want to achieve is to color the cells containing the largest 3 numbers in each row, right?

Let me explain that in a step-by-step manner below.

Custom Formula to Highlight Max | Largest 3 Values in Each Row – Google Sheets

Highlight Largest 3 Values in Each Row - Google Sheets

See the numbers highlighted in each row to understand what I am talking about.

In this type of conditional formatting, you will face three issues. So let’s address those issues in the step by step instructions below.

Normally to highlight the largest 3 values in each row, you can use the following formula in sheets.

=B2:B>=large($B2:$K2,3)

To apply, select the range B2:K, then go to Format > Conditional format and apply the above formula in the custom formula field.

See the above mentioned conditional format settings and one of the issues this formula has below.

Issue # 1: No Highlighting Happens When There Are Less Than Three Max Values

Please refer to this image for the format settings.

Highlighting Issue with Max 3 Values

The formula has an issue that reflects in the last row B5:K5.

What is that issue?

The range B5:K5 is unaffected by the highlighting!

Since there are only two values in the said row, the Large function fails to return the 3rd largest value. You can try it on your sheet yourself.

=large(B5:K5,3)

As a result, it would only return NUM! error. So there is no point to expect the conditional format to properly work in that row. We can address this issue as follows.

Issue # 2: Large Function NUM Error

Fill all the blank cells in the range B2:K5 with 0. So the just above formula will return 0 as the third largest value instead of NUM! error.

That makes sense in the conditional formatting but not practical in a growing range. The sheet will look ugly if you fill 0s in all the blank cells in a range like B2:K.

Let me explain how to solve this by modifying the formula used above to highlight the largest 3 values in each row.

To handle the Large function NUM! error, here we can wrap the ‘data’ with the function N as below.

=B2:B>=large(arrayformula(n($B2:$K2)),3)

I have modified $B2:$K2 to arrayformula(n($B2:$K2)). The N function is used not with a single cell but with a range. So we mustn’t forget to use ArrayFormula together.

Let’s see the output now and get ready to solve a new problem!

Highlighting Largest 3 Values in Each Row and Blanks

Issue # 3: Highlighting Largest 3 Values in Each Row Affects Blank Rows Too

When we solve one conditional format issue another one surfaces. Hopefully, this is the last one.

Can anyone guess why all the bank rows got highlighted?

It’s because the N function used in the above example makes the blank cells filled with 0.

If all the values in a row are 0 means the largest three values are 0. So obviously the entire row got highlighted.

How to solve this highlighting puzzle?

We can use AND logical operator as below.

Syntax:

AND(logical_expression1, [logical_expression2, …])

In this, use the just above formula as the logical_expression2. Use len($B2:$K2) as the logical_expression1.

You May Like: LEN Function in Google Sheets and Practical Use of It.

So the final formula to conditional format/highlight the largest 3 values in each row in Google Sheets will be as follows.

=and(len($B2:$K2),B2:B>=large(arrayformula(n($B2:$K2)),3))

Resources:

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.

Hierarchical Numbering Sequences in Excel

Creating hierarchical numbering sequences in an Excel spreadsheet can significantly improve the way you...

How to Easily Repeat a Sequence of Numbers in Excel

Excel offers multiple ways to accomplish tasks, and the simplicity of each approach depends...

Create a Sequence of Dates at Every Nth Row in Excel (Dynamic Array)

Would you like to create a sequence of dates in every nth row in...

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

4 COMMENTS

    • Hi, Chris,

      The same formula will work in a vertical range.

      For example, for the range C2:C15, you can use the following highlight rule.

      =and(len($C$2:$C$15),C2>=large(arrayformula(n($C$2:$C$15)),3))

  1. Hello,

    Is there a way to do this but not highlight a duplicate lower value? For instance, if my values are 50, 49, 48, 48, 40, and 30, I would only want 50, 49, and the first 48 highlighted, not both 48s.

    Thank you.

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.