Chapter 4: Lookup Functions

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

Chapter 4: Lookup Functions

Objectives:

Lookup Functions for Database Queries

 These functions are useful for finding specific data in a spreadsheet.


 =VLOOKUP(lookup_value, table_array, col_index_num, [range lookup]) - looks up a value in the
leftmost column of a table and returns a value in the same row from a column you specify
 =HLOOKUP(lookup_value, table_array, row_index_num, [range lookup]) - looks up a value in
the top row of a table and returns a value in the same column from a row you specify.
 =INDEX(array, row_num, col_num) - returns a value or reference of the cell at the intersection
of a particular row and column in a given range.
 =MATCH(lookup_value, lookup_array, match_type) - returns the relative position of an item in
an array that matches a specified value in a specified order

important Notes on Lookup Functions

 In the VLOOKUP and HLOOKUP functions, range lookup is optional. If this is omitted or set
as True, then the first column of the table must be sorted in ascending numerical order.
 If an exact match for the lookup_value is found in the first column, then Excel will return the
value the col_index_num of that row. If an exact match is not found, Excel will choose the row
with the largest value in the first column that is less than the lookup_value.
 If range lookup is False, then Excel seeks an exact match in the first column of the table range.
If no exact match is found, Excel will return #N/A (not available).
 We recommend that you specify the range lookup to avoid errors.

VLOOKUP FUNCTION

Looking for Exact Match

 The VLOOKUP function below looks up the value 53 (first argument) in the leftmost column of
the red table (second argument).

 The value 4 (third argument) tells the VLOOKUP function to return the value in the same row
from the fourth column of the red table.

 Note: the Boolean FALSE (fourth argument) tells the VLOOKUP function to return an exact
match. If the VLOOKUP function cannot find the value 53 in the first column, it will return a #N/A
error.
 Here's another example. Instead of returning the salary, the VLOOKUP function below returns
the last name (third argument is set to 3) of ID 79.

Approximate Match

 The VLOOKUP function below looks up the value 85 (first argument) in the leftmost column of
the red table (second argument). There's just one problem. There's no value 85 in the first
column.

 Fortunately, the Boolean TRUE (fourth argument) tells the VLOOKUP function to return an
approximate match. If the VLOOKUP function cannot find the value 85 in the first column, it will
return the largest value smaller than 85. In this example, this will be the value 80.

 The value 2 (third argument) tells the VLOOKUP function to return the value In the same row
from the second column of the red table.

First Match

 If the leftmost column of the table contains duplicates, the VLOOKUP function matches the first
instance. For example, take a look at the VLOOKUP function below.
Index Function

 =INDEX(array, row_num, col_num)


 The INDEX function works as a lookup procedure by returning the value in a particular row and
column of an array. For example, in the Sales Transactions database,

How to use Index Formula

 Below is a table showing people’s name, height and weight. We want to use the INDEX formula
to look up Kevin’s height… here is an example of how to do it.
 Follow these steps:
1. Type “=INDEX(” and select the area of the table then add a comma
2. Type the row number for Kevin, which is “4” and add a comma
3. Type the column number for Height, which is “2” and close the bracket
4. The result is “5.8”


Match Function

 =MATCH(lookup_value, lookup_array, match_type)


 In the MATCH function, lookup_value is value that you want to match in lookup_array, which
is the range of cells being searched. The match_type is either -1, 0, or 1. The default is 1.
 If match_type = 1, then the function finds the largest value that is less than or equal to
lookup_value.
o The values in the lookup_array must be placed in ascending order.
 If match_type = 0, MATCH finds the first value that is exactly equal to lookup_value.
o The values in the lookup_array can be in any order.
 If match_type = -1, then the function finds the smallest value that is greater than or equal
to lookup_value.
o The values in the lookup_array must be placed in descending order.

how to use the Match Fucntion

 Sticking with the same example as above, let’s use MATCH to figure out what row Kevin is in.
 Follow these steps:
1. Type “=MATCH(” and link to the cell containing “Kevin”… the name we want to look up
2. Select the all the cells in the Name column (including the “Name” header)
3. Type zero “0” for an exact match
4. The result is that Kevin is in row “4”


 Use MATCH again to figure out what column Height is in.

 Follow these steps:

1. Type “=MATCH(” and link to the cell containing “Height”… the criteria we want to look
up

2. Select all the cells across the top row of the table

3. Type zero “0” for an exact match

4. The result is that Height is in column “2”

3 How to Combine INDEX and MATCH

• Now we can take the two MATCH formulas and use them to replace the “4” and the “2” in the
original INDEX formula. The result is an INDEX MATCH formula.

• Follow these steps:

1. Cut the MATCH formula for Kevin and replace the “4” with it

2. Cut the MATCH formula for Height and replace the “2” with it
3. The result is Kevin’s Height is “5.8”

4. Congratulations, you now have a dynamic INDEX MATCH formula!

5.

You might also like