Case-Sensitive Reverse VLOOKUP in Google Sheets

Published on

Case-sensitive Reverse VLOOKUP refers to looking up a search key in a column case-sensitively and returning the corresponding value from a column to the left. How can we do this in the example below? Is it a complex task?

DateItem CodeQty
21/09/2024PRT 500 AA100
22/09/2024PRT 500 Aa75
23/09/2024HRD 129 Y100
24/09/2024PRT 900 X150
25/09/2024HRD 129 y90

We can achieve this using VLOOKUP with EXACT or INDEX-MATCH with EXACT. In terms of complexity, it’s a relatively simple task.

In the following example, we will case-sensitively look up an item code in column B and return the corresponding date from column A. This can be called a case-sensitive reverse (leftward) lookup in Google Sheets.

In this example, PRT 500 AA and PRT 500 Aa are distinct, showing the case sensitivity of the lookup.

Example of Case-Sensitive Reverse VLOOKUP

The following formula in cell F2 will look up PRT 500 Aa entered in cell E2 in column B and return the date 22/09/2024 from column A.

=ArrayFormula(
   VLOOKUP(TRUE, HSTACK(EXACT(B2:B6, E2), A2:A6), 2, FALSE
   )
)
Example of Case-Sensitive Reverse VLOOKUP

Unlike in Excel, you can extend the ranges B2:B6 and A2:A6 to B2:B and A2:A, allowing the formula to include future values in these columns.

Let me explain this formula step-by-step. Then we will move on to case-sensitive reverse VLOOKUP using an alternative INDEX-MATCH method.

Formula Breakdown

Syntax: VLOOKUP(search_key, range, index, [is_sorted])

Since VLOOKUP function can only search the first column of a range, for case-sensitive reverse VLOOKUP, we need to adjust the range accordingly.

  • Range: HSTACK(EXACT(B2:B6, E2), A2:A6) where:
    Virtual Range for Case-Sensitive Reverse VLOOKUP
    • EXACT(B2:B6, E2) checks if the text in E2 exactly matches each text in B2:B6, returning an array of TRUE or FALSE, with TRUE representing an exact match. This function needs ARRAYFORMULA to handle comparisons across a range.
    • HSTACK horizontally stacks the A2:A6 range alongside the array of TRUE/FALSE values, creating a two-column array for the lookup.
  • VLOOKUP(TRUE, …) searches for the first TRUE in the new virtual range and returns the corresponding value from the second column (the date).
  • The last argument FALSE ensures we are doing an exact match rather than a partial match, as the range is not sorted.

INDEX-MATCH Alternative for Case-Sensitive Reverse VLOOKUP

This is an alternative to the above VLOOKUP formula:

=INDEX(A2:A6, MATCH(TRUE, EXACT(B2:B6, E2), 0))

This method is quite straightforward if you’ve reviewed the case-sensitive VLOOKUP example above.

  • EXACT(B2:B6, E2) returns an array of TRUE or FALSE, where TRUE represents an exact match.
  • The MATCH function finds the first occurrence of TRUE in this array and returns the relative position.
  • The INDEX function uses that position to retrieve the corresponding value from the date column.

Since INDEX operates as an array formula, the use of the ARRAYFORMULA function is not necessary for EXACT.

It’s that simple! Test both formulas and see which one you prefer. I recommend using INDEX-MATCH for case-sensitive reverse VLOOKUP due to its simplicity.

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.

Filter Top N per Category in Excel (Using FILTER & COUNTIFS)

You can use a combination of FILTER and COUNTIFS to filter the top N...

Rank per Group in Excel

You have two groups of 20 students each. How do you determine the rank...

Real-Time Excel Filtering Using Combo Box & FILTER Function

In this tutorial, you’ll learn how to set up real-time Excel filtering using a...

Google Sheets: Extract Top N per Group from Query Aggregation

When working with grouped and aggregated data in Google Sheets, you might need to...

More like this

Google Sheets: Extract Top N per Group from Query Aggregation

When working with grouped and aggregated data in Google Sheets, you might need to...

How to Extract Top N from Aggregated Query Results in Google Sheets

To summarize data in Google Sheets, you can use the QUERY function. However, if...

How to Use RANK IF in Google Sheets (Conditional Ranking)

You can use the RANK function to rank values in an entire dataset. But...

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.