This is part of our Excel Interview Questions series. Subscribe for more questions.
VLOOKUP or INDEX+MATCH? When you should use each function and why?
This is such a great question to ask in interviews. So in my first installment of Excel interview questions, let me answer it.
Watch the answer – video
I made a video explaining both formulas and how to answer such interview question in detail. There is a quick demo of VLOOKUP, INDEX&MATCH and array use of INDEX too. Watch it below or on Chandoo.org YouTube Channel.
What is VLOOKUP?
VLOOKUP is Excel’s data search function. Given some data, you can use VLOOKUP to answer questions about it. Say you have data like this,
You can use VLOOKUP to answer questions like,
- How many customers did “Jonathan” have?
- What is the net sales for “Jessy“?
Example VLOOKUP formulas:
To answer above questions, we can use below formulas:
- VLOOKUP(“Jonathan”, Sales, 2, false)
- VLOOKUP(“Jessy”, Sales, 3, false)
What is INDEX+MATCH?
INDEX+MATCH combination formula helps you answer same questions as VLOOKUP, but they also allow you to answer questions about data from anywhere (not just the left most column).
For example, you can answer questions like:
- Who had net sales of 2,133?
- Whose profit is 570?
- What is net sales of “Jessy“?
Example INDEX+MATCH formulas:
To answer above questions, you can use below INDEX+MATCH formulas.
- =INDEX(Sales[Sales Person], MATCH(2133, Sales[Net Sales], 0))
- =INDEX(Sales[Sales Person], MATCH(570, Sales[Profit / Loss], 0))
- =INDEX(Sales[Net Sales], MATCH(“Jessy”, Sales[Sales Person], 0))
When to use VLOOKUP?
VLOOKUP is a good option when you have simple data or lookup situations. Let’s say you just need to lookup details for someone or something out of a any sized data-set. Use VLOOKUP. It is easy to use and works as long as you are looking up on the left and returning values from right.
When to use INDEX+MATCH?
INDEX+MATCH combination is good for,
- Looking up anywhere in data (not just in the left)
- with large data-sets
- when performing multiple lookups (usually thousands or more)
Why not just use INDEX+MATCH all the time?
This depends on your style. I prefer to use VLOOKUP for simple situations as it is easy to write. But whenever I am building a complex report or model with thousands of lookups, I try to use INDEX+MATCH formulas.
How to make lookups faster?
The best way to make lookups faster is by avoiding them. We can use relationships feature of Excel to connect tables and analyze without writing multiple lookup formulas.
But if you can’t use that, then rely on INDEX+MATCH structure as it allows better performance. To speed up lookups, follow below ideas:
- Sort your data. If you can sort your data, that will make lookups very fast. You can omit the FALSE or 0 parameter in VLOOKUP / MATCH formulas with sorted data. Of course, the result will be wrong if what you are looking for is not there. But this can be solved by using an IF formula like this:
- On sorted tables, =IF(MATCH(“Jessica”,Sales[Sales Person])<>”Jessica”, “Not found”, INDEX(Sales[Net Sales], MATCH(“Jessica”, Sales[Sales Person])))
- Lookup once, get many times. For example, if you have multiple INDEX+MATCH formulas all doing same MATCH, then calculate the MATCH result once in a cell and refer to that in INDEX formulas.
- Use array notation of INDEX. We can return arrays with INDEX formula. This tends to be faster than writing multiple INDEX formulas.
- Use Dynamic Array functions (NEW). Excel 2019 is going to introduce powerful array functions like FILTER(), SORT() etc to dynamically generate array of results from your questions. If you have access to them, consider using them over normal array INDEX formulas.
Learn more about lookup formulas
If you want to learn all about VLOOKUP, INDEX+MATCH or other lookup techniques, check these links.
- All about VLOOKUP and INDEX+MATCH formulas
- VLOOKUP multiple matches – trick
- INDEX formula and arrays
- Lookup last value
- The ultimate lookup trick – Multi-condition vlookup
What is your answer?
Imagine you have this question in an interview. How would you answer it. Please share your response in comments.
Also, if you have any suggestions for Excel Interview Questions series, please post or email. 🙂