TABLE OF CONTENTS

XMATCH Function Excel

The XMATCH function in Excel returns the position of an item in an array.

4 minute read

XMATCH Function

The XMATCH function in Excel returns the position of an item in an array. By default, an exact match is required. The syntax for the XMATCH Function is:

=XMATCH(lookup_value, lookup_array, [match_mode], [search_mode])

Breakdown of the inputs (arguments). The inputs with parenthesis [ ] are optional:

  • Lookup_value: the value you’re interested in finding within the dataset
  • Lookup_array: the dataset where you can find the lookup value. This is typically a column.
  • [match_mode]: choose the type of match. Options are: exact, exact or next smaller, exact or next larger, and wildcard match (we’ll cover these in examples below).
  • [search_mode]: choose the search mode. Option are: first to last, last to first, or sorted ascending or descending.

Now that we understand the syntax, let’s look at some examples from easy to hard. 

XMATCH Example 1 (Basic)

XMATCH Example 1

In the table above, suppose you want to find the location of Germany within the list of countries. For this, we would select Germany in cell F3 as the lookup_value, and the range B3:B9 as the lookup_array. This will give us an answer of 3, as Germany is located in third position within the list of countries.

The XMATCH function used in this scenario is not very useful. So let’s explore more relevant examples below.

XMATCH Example 2 (Intermediate)

XMATCH Example 2

In the table above, suppose we want to know who got closest to our budget of $10,000 without surpassing it. For this, we can use the XMATCH Function with the match_mode. As the match_mode option, we’ll use the -1 which stands for the exact match or next smaller item. 

This helps us find who came closest to reaching full budget without surpassing it. In this case, it’s Harley from Germany. 

XMATCH Example 3 (Advanced)

XMATCH Example 3

What happens if we don’t know the exact name? For example, companies often have names such as Nike Inc. for Nike, or Puma Co. for Puma. Is there a way for us to use the XMATCH in this scenario? Yes! That’s where the wildcard match_mode comes handy. 

For this, suppose we want to find the position of Puma within the table. However, you’ll notice that Puma is not an exact match, as it’s written as Puma Co. in the data table. To work around this, we’ll use the XMATCH with a Wildcard. 

First, add the lookup_value, and at the end of the cell, add an ampersand (&) and an asterisk (*) between quotations (“ “). This tells Excel that anything after the lookup_value can be ignored. Now, we just need to add the number 2 under the search mode to activate the wildcard. 

The result is position 3, despite Puma and Puma Co. not being exact matches. 

XMATCH Example 4 (Expert)

XMATCH Example 4

The XMATCH function is most useful when combined with other Excel functions such as the INDEX. So let’s look at an example below:

In the table above, we want to find the revenue for Italy. If we only used the XMATCH function, it would give us the position, and not the actual amount of revenue. That’s where the INDEX XMATCH combination comes handy.

In the INDEX function, we first add the array which is the result array (in this case the revenue figures). Then, as the row_num we add the XMATCH function. Adding a function inside of another function is known as nesting in Excel. The syntax for the XMATCH is the same as the previous examples. 

The final result is the revenue amount, instead of the position number we would have gotten just by using the XMATCH function.  

XMATCH Function Errors

The XMATCH Function can show an #N/A error when there is no match. For example, if you’re looking for “Sam” within a column of names, and “Sam” is not a name in that column, it will give the #N/A error.

The #VALUE! error happens when there’s an error in the values added to the formula. For example, in the match_mode, if you added a 3, which is not an option that’s available, it would return a #VALUE! error. 

XMATCH vs MATCH Functions

The XMATCH is the successor of the MATCH function in Excel. The XMATCH is more flexible with features such as the search mode allowing you to search in different orders, and the wildcard match mode for partial matches of a value.

Alternatives to the XMATCH

Instead of finding the position number, if you’re interested in finding the actual value in that position, the XLOOKUP function is probably the easiest solution. 

Another option that’s arguably more difficult is the INDEX MATCH function as it requires two separate formulas (the INDEX and the MATCH) to make it work.

Additional Resources

If you found this article useful, consider checking out our Excel for Business & Finance Course, where we help students learn the technical skills needed to perform in competitive finance and investment roles. Use this course to join our students who have landed roles at Goldman Sachs, Amazon, Bloomberg, and other great companies! 

Other Articles You Might Find Helpful

Introduction

Building a cash flow statement from scratch using a company income statement and balance sheet is one of the most fundamental finance exercises commonly used to test interns and full-time professionals at elite level finance firms.

Test hyperlink

Image caption goes here
Sample Image Insertion
Dolor enim eu tortor urna sed duis nulla. Aliquam vestibulum, nulla odio nisl vitae. In aliquet pellentesque aenean hac vestibulum turpis mi bibendum diam. Tempor integer aliquam in vitae malesuada fringilla.

Elit nisi in eleifend sed nisi. Pulvinar at orci, proin imperdiet commodo consectetur convallis risus. Sed condimentum enim dignissim adipiscing faucibus consequat, urna. Viverra purus et erat auctor aliquam. Risus, volutpat vulputate posuere purus sit congue convallis aliquet. Arcu id augue ut feugiat donec porttitor neque. Mauris, neque ultricies eu vestibulum, bibendum quam lorem id. Dolor lacus, eget nunc lectus in tellus, pharetra, porttitor.

  • Test Bullet List 1
  • Test Bullet List 2
  • Test Bullet List 3
"Ipsum sit mattis nulla quam nulla. Gravida id gravida ac enim mauris id. Non pellentesque congue eget consectetur turpis. Sapien, dictum molestie sem tempor. Diam elit, orci, tincidunt aenean tempus."

Tristique odio senectus nam posuere ornare leo metus, ultricies. Blandit duis ultricies vulputate morbi feugiat cras placerat elit. Aliquam tellus lorem sed ac. Montes, sed mattis pellentesque suscipit accumsan. Cursus viverra aenean magna risus elementum faucibus molestie pellentesque. Arcu ultricies sed mauris vestibulum.

Conclusion

Morbi sed imperdiet in ipsum, adipiscing elit dui lectus. Tellus id scelerisque est ultricies ultricies. Duis est sit sed leo nisl, blandit elit sagittis. Quisque tristique consequat quam sed. Nisl at scelerisque amet nulla purus habitasse.

Nunc sed faucibus bibendum feugiat sed interdum. Ipsum egestas condimentum mi massa. In tincidunt pharetra consectetur sed duis facilisis metus. Etiam egestas in nec sed et. Quis lobortis at sit dictum eget nibh tortor commodo cursus.

Odio felis sagittis, morbi feugiat tortor vitae feugiat fusce aliquet. Nam elementum urna nisi aliquet erat dolor enim. Ornare id morbi eget ipsum. Aliquam senectus neque ut id eget consectetur dictum. Donec posuere pharetra odio consequat scelerisque et, nunc tortor.
Nulla adipiscing erat a erat. Condimentum lorem posuere gravida enim posuere cursus diam.

Kenji Farre
Kenji Farre
Senior Instructor

Ready to Level Up Your Career?

Learn the practical skills used at Fortune 500 companies across the globe.