 # Lookup in 2d table using INDEX & MATCH function In this article, we will learn how to look up values in 2d table using an INDEX-MATCH-MATCH function in Excel.

Scenario:

Assume that you need to do multiple look ups from a table that has hundreds of columns. In such cases, using different formulas for each lookup will take too much time. How about creating a dynamic lookup formula that you can look up by provided header. Yes, we can do this. This formula is called INDEX MATCH MATCH formula, or say a 2d lookup formula.

How to Solve the Problem?

For the formula to understand first we need to revise a little about the following functions

The INDEX function returns the value at a given index in an array.

MATCH function returns the index of the first appearance of the value in an array ( single dimension array ).

Now we will make a formula using the above functions. Match function will return the index of the lookup value1 in the row header field. And another MATCH function will returns the index of the lookup value2 in the column header field. The index numbers will now be fed into the INDEX function to get the values under the lookup value from the 2D table data.

Generic Formula:

= INDEX ( data , MATCH ( lookup_value1, row_headers, 0 , MATCH ( lookup_value2, column_headers, 0 ) ) )

Data: array of values inside the table without headers

lookup_value1 : value to lookup in the row_header.

row_headers : Row Index array to look up.

lookup_value1 : value to lookup in the column_header.

column_headers : column Index array to lookup.

Example:

The above statements can be complicated to understand. So let’s understand this by using the formula in an example

Here we have a list of scores gained by students with their Subject list. We need to find the Score for a specific Student (Gary) & Subject (Social Studies) as shown in the snapshot below. The Student value1 must match the Row_header array and Subject value2 must match the Column_header array.
Use the formula in the J6 cell:

= INDEX ( table , MATCH ( J5, row, 0 , MATCH ( J4, column, 0 ) ) )

Explanation:

• The MATCH function matches the Student value in J4 cell with the row header array and returns its position 3 as a number.
• The MATCH function matches the Subject value in J5 cell with the column header array and returns its position 4 as a number.
• The INDEX function takes the row and column index number and looks up in the table data and returns the matched value.
• The MATCH type argument is fixed to 0. As the formula will extract the exact match. Here values to the formula are given as cell references and row_header, table and column_header given as named ranges.
As you can see in the above snapshot, we got the Score obtained by student Gary in Subject Social Studies as 36 .
It proves the formula works fine and for doubts see the below notes for understanding.

Now we will use the approximate match with row headers and column headers as numbers. Approx match only takes the number values as there is no way it applies to text values

Here we have a price of values as per the Height & Width of the product. We need to find the Price for a specific Height (34) & Width (21) as shown in the snapshot below. The Height value1 must match the Row_header array and Width value2 must match the Column_header array.
Use the formula in the K6 cell:

= INDEX (data , MATCH (K4, Height, 1 , MATCH ( K5, Width, 1 ) ) )

Explanation:

• The MATCH function matches the Height value in K4 cell with the row header array and returns its position 3 as a number.
• The MATCH function matches the Width value in K5 cell with the column header array and returns its position 2 as a number.
• The INDEX function takes the row and column index number and looks up in the table data and returns the matched value.
• The MATCH type argument is fixed to 1. As the formula will extract the approximate match. Here values to the formula are given as cell references and row_header, data and column_header given as named ranges as mentioned in the snapshot above.

As you can see in the above snapshot, we have the Price obtained by height (34) & Width (21) as 53.10 .  It proves the formula works fine and for doubts see the notes below for more understanding.
Notes:

1. The function returns the #NA error if the lookup array argument to the MATCH function is 2 D array which is the header field of the data..
2. The function matches the exact value as the match type argument to the MATCH function is 0.
3. The lookup values can be given as cell reference or directly using quote symbol ( " ) in the formula as arguments.

Hope you understood how to use the Lookup in 2 D table using INDEX & MATCH function in Excel. Explore more articles in Excel lookup value here. Please feel free to state your queries below in the comment box. We will certainly help you.

Related Articles

Use INDEX and MATCH to Lookup Value : INDEX & MATCH function to look up value as required.

SUM range with INDEX in Excel : Use INDEX function to find the SUM of the values as required.

How to use the SUM function in Excel : Find the SUM of numbers using the SUM function explained with example.

How to use the INDEX function in Excel : Find the INDEX of array using the INDEX function explained with example.

How to use the MATCH function in Excel : Find the MATCH in the array using the INDEX value inside MATCH function explained with example.

How to use LOOKUP function in Excel : Find the lookup value in the array using the LOOKUP function explained with example.

How to use the VLOOKUP function in Excel : Find the lookup value in the array using the VLOOKUP function explained with example.

How to use the HLOOKUP function in Excel : Find the lookup value in the array using the HLOOKUP function explained with example.

Popular Articles

50 Excel Shortcut to Increase Your Productivity

Edit a dropdown list

Absolute reference in Excel

If with conditional formatting

If with wildcards

Vlookup by date

Join first and last name in excel

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.