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. 🙂
25 Responses to “VLOOKUP or INDEX+MATCH? – Excel Interview Question – 01”
I use index + match when the lookup value is to the left of the criteria.
Asking this question is like asking "Who is the best/strongest comic super hero character" in the comic book store.
🙂
haha... We can all agree that these formulas are indeed superheros 🙂
Has anyone else noticed that vlookups and index/match seem to be working faster in recent months? I'm blindly attributing to this a program update of some sort. I regularly do vlookups & I/M on hundreds of thousands of rows and what used to take up to 45 minutes is now done in seconds. Some co-workers have noticed the same thing. Speed is no longer an issue.
Another option to speedup vlookup is to use double vlookup for larger datasets
https://exceljet.net/formula/faster-vlookup-with-2-vlookups
For beginners it would be great to start with Lookups then jump to Indiex/Match
Excel team did improve performance of vlookups and other functions
https://techcommunity.microsoft.com/t5/Excel-Blog/Excel-performance-improvements-now-take-seconds-running-Lookup/ba-p/254199
Good one Ricardo. Thanks for sharing this.
No need to share this comment Chandoo. I'm a big fan of yours. Have learned a lot, and I consider myself an "expert"...you're at another level. Keep sharing your knowledge!
How does vlookup/index+match compare to opening the table as a datasource and using sql queries?
If your aim is to simply merge (join) both tables, then you are better off doing it outside Excel. SQL or Power Query are equally best places to do it. I would go with PQ as it gives me more options.
I use INDEX/MATCH almost exclusively, especially if I'm working with tables. I never worry about where my lookup column is, and if I use the column header descriptions for the second MATCH argument (of course, you can use a MATCH formula for the column argument in VLOOKUP), then my lookups are dynamic, i.e. the data array can be modified and the INDEX/MATCH doesn't lose it's way.
Since I am beginner here; I would prefer vlookup for now...
It depends on the report.
If it's something that needs to be once, I'll use VLookup or Index+Match (VLookup for quick-and-dirty things, Index+Match for more complex things).
If it's something that will need to be re-run on a regular basis, I'll use PowerQuery.
I always use Index+match as Vlookup/Hlookup are too quirky to deal with. Index+match always works the same way and are particularity useful with Tables.
I am with Mark Knochel. I use Index match exclusively because it does everything VLookup does + more.
Index + Match always
I use vlookup mostly when I am working with simple and clean data, INDEX + Match when I am working with external connections that require complex and dynamic formulas
Chandoo, in your closing bullets, for the one about sorting data, you forgot an INDEX in your example formula. Your MATCH for Jessica will never be Jessica, it will be the numerical position of Jessica. So you need to wrap it in an INDEX that also references the Sales[Sales Person] column.
As for VLOOKUP versus INDEX-MATCH, I will join the chorus of those who use only the latter for all the advantages they (and you) have already noted and then some. I have not used VLOOKUP in at least a decade, and I will go to my grave encouraging others to throw it in the trash and never look back. I even tell people to consider it to be a cuss word that should be purged from our collective functional vocabulary.
Knowing both ways is one thing, because there will always be that file you inherit from someone who used VLOOKUP. But actually using both is like saying you know how to write a book both by hand with a pen and by computer with your fingertips and then saying you prefer the ink pen because it's harder?!? Because it's a nostalgic trip down memory lane...maybe...but never because it's the better or easier choice. The pen will take longer (on average), and correcting mistakes will be a nightmare, while the computer is faster (on average) with corrections being a breeze. INDEX-MATCH can do literally everything VLOOKUP can even dream of and more, so let's move on and never cuss again.
hi chandoo sir
my name is dheeraj nd i m from india,
ofcourse i calk u sir i want to know about vlookup and average so i would like to know find average.
regards
Dheeraj
Hey there,
I have searched high and low for a way to compare 2 tables in the same excel file and populate a third containing unique names from both. Is this doable using power query or any other way?
Hi, Chandoo,
Thanks for your tips. Much appreciated.
So far I use I+M for case sensitive search together with EXACT. Vlookup doesn't see difference between C and c.
BTW re speed. I've checked both Vlookup and I+M to search 421K rows main table vs 46K rows table. Both of my searched took the same time 2:15 min.
I+M are my choice. Work for looking on both sides, can transpose an array etc.
Another big plus for INDEX+MATCH over VLOOKUP is that it allows you to change the structure of your table.
Want to insert an extra column in the middle? INDEX+MATCH will seamlessly update your reference to column G:G is now column H:H (or, of course, if you're using named ranges then it's even easier), whereas with VLOOKUP you need to remember to go through and change the column reference number in every instance where it is pointing to a column to the right of the one you've added.
Dear Chandoo,
I am practicing with Sample Data sheet to find the sales for one region using VLOOKUP & INDEX+MATCH, but I am not able to get the desired result.
But when using SUMIFS, I am able to get the result.
Please can you help in solving this issue?