XMATCH Function Alternatives in Google Sheets

Published on

If you’re looking for alternatives to the Excel XMATCH function in Google Sheets, you’re in the right place! This post provides alternative formulas to match nearly all XMATCH variations.

Update: The XMATCH function is now available in Google Sheets. Learn more here – XMATCH Function in Google Sheets (Formula Examples).

Although Google Sheets now supports the XMATCH function, alternative formulas can still be useful. For those unfamiliar with XMATCH, it’s a modern lookup function that returns the relative position of a value within a row or column.

In Google Sheets, the MATCH function can serve as an alternative to XMATCH. However, achieving the same functionality may require combining MATCH with other functions. So, learning MATCH alone won’t be enough!

Don’t worry—I’ll guide you through using MATCH as an XMATCH alternative, including some additional functions.

XMATCH Function Alternatives in Google Sheets

In Excel, we commonly use XMATCH for the following purposes:

Sr. No.DescriptionMatch TypeResponse to Duplicates
1Find the relative position of an item in a row or columnExactFirst value
2-do-Exact Last value
3-do-Exact or Next Largest First value
4-do- Exact or Next Largest Last value
5-do- Exact or Next Smallest First value
6-do- Exact or Next Smallest Last value

Take note of the last two columns in the table. When creating XMATCH alternatives in Google Sheets, ensure that the formulas work with both numbers and text strings.

Here are six alternative XMATCH formulas in Google Sheets based on the scenarios in the table above:

Example 1 – Relative Positions in a Numeric Array

Consider the following vertical array in Google Sheets, where we’ll test six XMATCH alternatives.

Sample Numeric Data to Test XMATCH Alternatives
image_1
  • Lookup range/array: A2:A10, containing numeric values.
  • Note: You do not need to sort the range for these examples.

Below are the formulas in order of the match type and response to duplicates from the table above. Replace “Lookup_Value” with the value you’re matching.

  1. Exact match, first occurrence
    • Google Sheets Formula: =MATCH(Lookup_Value, A2:A10, 0)
    • Excel Formula: =XMATCH(Lookup_Value, A2:A10, 0, 1)
  2. Exact match, last occurrence
    • Google Sheets Formula: =ArrayFormula(MATCH(1, 1/(A2:A10=Lookup_Value), 1))
    • Excel Formula: =XMATCH(Lookup_Value, A2:A10, 0, -1)

In the following examples, we’ll use the additional functions SORTN and FILTER.

  1. Exact match or next largest, first occurrence
    • Google Sheets Formula: =ArrayFormula(MATCH(1, 1/(A2:A10=SORTN(FILTER(A2:A10, A2:A10>=Lookup_Value))), -1))
    • Excel Formula: =XMATCH(Lookup_Value, A2:A10, 1, 1)
  2. Exact match or next largest, last occurrence
    • Google Sheets Formula: =ArrayFormula(MATCH(1, 1/(A2:A10=SORTN(FILTER(A2:A10, A2:A10>=Lookup_Value))), 1))
    • Excel Formula: =XMATCH(Lookup_Value, A2:A10, 1, -1)
  3. Exact match or next smallest, first occurrence
    • Google Sheets Formula: =ArrayFormula(MATCH(1, 1/(A2:A10=SORTN(FILTER(A2:A10, A2:A10<=Lookup_Value), 1, 0, 1, 0)), -1))
    • Excel Formula: =XMATCH(Lookup_Value, A2:A10, -1, 1)
  4. Exact match or next smallest, last occurrence
    • Google Sheets Formula: =ArrayFormula(MATCH(1, 1/(A2:A10=SORTN(FILTER(A2:A10, A2:A10<=Lookup_Value), 1, 0, 1, 0)), 1))
    • Excel Formula: =XMATCH(Lookup_Value, A2:A10, -1, -1)

Example 2 – Relative Positions in a Text Array

The six formulas above work equally well with text arrays. Here’s an example showing their results for a text array. You can use the same lookup range and formulas.

XMATCH Alternatives Using Text Criteria
image_2

If you’re an Excel or Google Sheets user interested in the original XMATCH formulas, the Excel counterparts provided above will also work in Google Sheets.

That’s it for XMATCH function alternatives in Google Sheets! Thank you for reading. Enjoy exploring these formulas!

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.

How to Extract Numbers from Text in Excel with Regex

You can use the REGEXEXTRACT or REGEXREPLACE functions to easily extract numbers from text...

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

How to Use OFFSET and XMATCH Functions Together in Excel

We often use the OFFSET and XMATCH functions together to match a value in...

How to Calculate Maximum Drawdown in Excel and Google Sheets

You can use the following dynamic array formula to calculate maximum drawdown (MDD) in...

More like this

How to Calculate Maximum Drawdown in Excel and Google Sheets

You can use the following dynamic array formula to calculate maximum drawdown (MDD) in...

Lookup Previous Values Dynamically in Excel and Google Sheets

Sometimes, you may want to look up the previous values relative to the current...

Sort Data but Keep Blank Rows in Excel and Google Sheets

Using a dynamic array formula or the FILTER command, we can sort data and...

2 COMMENTS

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.