HomeGoogle DocsSpreadsheetVlookup to Return Only Values from Max Rows in Google Sheets

Vlookup to Return Only Values from Max Rows in Google Sheets

Published on

Find here all that you want to know about Vlookup in Max Rows in Google Sheets. You can tune the Vlookup to return only values from Max Rows in Google Sheets.

Lots of spreadsheet-related tasks require Vlookup in one way or another. So learning this function in its all possible variations will give you an upper hand in data manipulation.

Let us come back to our topic, i.e., Vlookup in Max Rows in Google Sheets. I am considering the below points in this Google Sheets tutorial.

  1. Find max value in a column and return value from the next column.
  2. Lookup a search key (possibly a string) and return the max value or value from the max row. That means the search key will be in the table multiple times. We only want the max value or any other value from the max value row of this key.
  3. How to use multiple search keys and return multiple max values or multiple values from the max row?

In concise, this tutorial is all about Max in Vlookup in Google Sheets. So here we go.

All About Vlookup in Max Rows in Google Sheets

Learn how to use Vlookup to return only values from the max rows in Google Sheets. You can learn this Vlookup Max concept under different subcategories below.

Find Max Value and Return Value from the Next | Adjoining Column

For this type of lookup, you can use the MAX function with Vlookup. Instead of feeding a search key directly in Vlookup, let the MAX return the max value as the search key.

=vlookup(max(A2:A9),A2:B9,2,0)
max value as the search key in Vlookup

In most cases, your column that contains the max value will be second, third, or fourth.

If so, you can flip the columns using the ArrayFormula in Vlookup. As you may know, the Vlookup in Sheets can only search down the first column for the key.

Assume in your Sheets, the name column is the first column, and the Score column is the second. Then use the formula as below.

=ArrayFormula(vlookup(max(B2:B9),{B2:B9,A2:A9},2,0))

So you have just learned the basics of using MAX in Vlookup in Google Sheets.

We are discussing how to use Vlookup in Max Rows in Google Sheets. Here is the second tip.

You May Like: Find Min, Max in a Matrix and Return a Value from the Same Row.

Lookup a Search Key and Return the Max Value or Value from the Max Value Row

Here the search key is not the max value.

This time you have the search key (text string) to search down the first column.

But the first column may or may not contain the search key multiple times.

How to return the max value or any other value of the search key from the row that contains the max value?

=vlookup("Student 2",sort(A2:B9,2,false),2,false)
search and find max value using Vlookup

I have used the SORT function with Vlookup here.

Without using SORT, the Vlookup formula would return the value 550 that is in cell B5. Because the search key “Student 2” is first appearing in that row.

I have sorted the data range in descending order based on column 2.

It puts the max values on the top. So, the max value row # 6 will be on top of the current row #5.

Here also you can flip the columns in Vlookup as we have done in example # 1 above.

Here is another notable point.

If you want to look up a search key and return value from any column from the Max row, you only need to change the column index in the formula.

For example, I have a three-column dataset that contains;

Student names in the first column, scores in the second column, and random dates in the third column.

You can return the date corresponding to the max score of the search key as below.

=vlookup("Student 2",sort(A2:B9,2,false),3,false)

Now see one advanced Max Value in Vlookup tip. Here I am following the above Vlookup max example.

The only difference is in the use of multiple search keys.

Vlookup to Only Return Values from Max Rows in Sheets (Multiple Search Keys)

See this example. You can use the just above formula with some changes.

What are those changes?

E.g.:-

=ArrayFormula(vlookup(E2:E4,sort(A2:C10,2,false),2,false))
Vlookup to Only Return Values from Max Rows

This formula may look complex, but it is simple to understand.

Multiple Max in Vlookup – Formula Logic

Here we have the Vlookup search keys in the range E2:E4, and that is the student names.

What we want is their max scores in Column B.

As we have done earlier, sort the ‘Score 1’ column B in descending order within the Vlookup.

Use the search key as a range E2:E4 instead of “Student 2” in the earlier formula.

Further, use the ArrayFormula as we want an array result.

Vlookup Alternative to Return Values from Max Rows (Using SORT + SORTN)

In Vlookup we have used the SORT to sort the ‘Score 1’ column in descending order. It places the higher scores on the top.

sort higher scores in sortn

Now take a look at column A.

If you can remove the duplicates, I mean the second and third occurrences of the same student names, then the three student names and their max scores will only be left.

In this workaround, I have wrapped that SORT formula with the SORTN as below.

=sortn(sort(A2:C10,2,false),9^9,2,1,true)

Note:- Unlike Vlookup, there is no need to specify the criteria separately.

The SORTN removes the duplicates based on the Student names. Want to know the parameters used in SORTN above.

  • 9^9 – You can replace this with 1000 or any large number as its role is ‘n’ (infinite).
  • 2 = it’s the display_ties_mode in SORTN.
  • 1 – sort column (the column to unique).
  • true – sort order.

Must Read: Remove Duplicates in Google Sheets [The Complete Guide and Sample Sheet]

I mean, the SORTN + SORT combo alone would return the below result, and that’s the max rows! This tip is entirely new to you, right?

Student 150127/07/2018
Student 258027/07/2018
Student 354027/07/2018

That’s all about Max in Vlookup in Google Sheets. Enjoy!

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.

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

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;...

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,...

4 COMMENTS

  1. What if I needed the same (Return Values from Max Rows) but for unique First Name + Last Name combinations?
    This way, I would have John Doe1, John Doe2, Robert Doe2, each of which is a unique student I need to obtain the max score.
    How will the Vlookup formula change?
    Array A2:B (where A = student’s first name, B = student’s last name) doesn’t seem to work.

    • Hi, Maksym Mukhin,

      Range A2:C.

      A2:A – First Name (text string)
      B2:B – Last Name (text string)
      C2:C – Score (numeric)

      Formula # 1:

      =vlookup("John Doe1",sort({A2:A&" "&B2:B,C2:C},2,false),2,false)

      Formula # 2:

      To return a table.

      =sortn(sort(A2:C,1,1,2,1,3,0),9^9,2,index(sort(A2:C,1,1,2,1,3,0),0,1)&
      index(sort(A2:C,1,1,2,1,3,0),0,2),0)

    • Hi, Harry,

      Replace Max with Min. Also wherever I have used SORT, instead of sorting in descending (false) order, sort the column2 in ascending order (true).

      Best,

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.