0% found this document useful (0 votes)
20 views14 pages

Lookup Exercises

The document contains a list of employees, their IDs, names, locations, salaries, and ages. It includes queries about specific employee information such as names, ages, locations, and salaries, along with explanations of how to use Excel functions like VLOOKUP and XLOOKUP for data retrieval. Additionally, it provides examples of using these functions for various lookup scenarios.

Uploaded by

rayscrooner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views14 pages

Lookup Exercises

The document contains a list of employees, their IDs, names, locations, salaries, and ages. It includes queries about specific employee information such as names, ages, locations, and salaries, along with explanations of how to use Excel functions like VLOOKUP and XLOOKUP for data retrieval. Additionally, it provides examples of using these functions for various lookup scenarios.

Uploaded by

rayscrooner
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Below is a list of the employees who work in your company:

Employee ID Name Location


56815 Garry Manship Hong Kong
51186 William Johnson Berlin
51511 Thomas Bettle Bangkok
50890 Ian Nash Cairo
53700 Margaret Turley Shanghai
55879 Michael Kaye Capetown
59848 Paul Bell Bangkok
58369 Thomas Davies Capetown
50217 Eric Green Warsaw
50695 Williamr Black Cairo
59673 Estelle Cormack Hong Kong
52130 Christopher Fallon Delhi

What is the name of Employee ID 58369?

What's the age of Estelle Cormack?

Return the Location of the following employees:

Employee ID Location
55879
50217
50695

Find the Salary of the following employees:

Name Salary
Ian Nash
Johnny Slash
Estelle Cormack
Salary Age
13836 25
11771 32
13046 35
18276 32
19327 26
18996 35
10387 25
12566 37
16406 42
15784 43
10959 30
14562 32
Below is a list of the employees who work in your company:

Employee ID Name Location Salary Age


56815 Garry ManshiHong Kong 13836 25
51186 William John Berlin 11771 32
51511 Thomas BettlBangkok 13046 35
50890 Ian Nash Cairo 18276 32
53700 Margaret TurShanghai 19327 26
55879 Michael KayeCapetown 18996 35
59848 Paul Bell Bangkok 10387 25
58369 Thomas DavieCapetown 12566 37
50217 Eric Green Warsaw 16406 42
50695 Williamr Blac Cairo 15784 43
59673 Estelle CormaHong Kong 10959 30
52130 Christopher FDelhi 14562 32

1 What is the name of Employee ID 58369Thomas DavieThomas Davies

Answer First, a quick explanation of the VLOOKU


VLOOKUP function is used when you want to find a value in a table and return its corresponding value fro
The best example would be a phone book: You are looking for the number of your friend Anthony, so you look up

So what's the syntax of V


=VLOOKUP(lookup_value,table_array,col_index_num,[range_lookup])

lookup_valueWhat we are looking for – this could be a text, number, or a single cell reference
table_array The range in which we will lookup for our value and its corresponding result. Please note that the ra
col_index_n What is the column number from which we want to return the result? The number should be relati
[range_lookuWhich range lookup method should be used. 0 is the default, so you should always type 0 (or FALSE
1 stands for “Approximate match”, and it should not be used on most cases so we’ll skip it for now.

Let's get back to our exampThomas Davies

Function arg Value used Explanation


lookup_value 58369 In our example, we asked to lookup the value 58369. Please note that if the value was

table_array $B$3:$F$15 Our table array in this example is $B$3:$F$15. The $ signs indicate that B3:F15 is an ab
we will not have a problem as the lookup range will stay the same.
Please note that although this example doesn’t require that we use absolute referenc

col_index_n 2 This is the column number which represents the column from which we retreive our r
[range_looku 0 0 means EXACT match - Return my result based on exact match only. We will use 0 in

2 What's the age of Estelle 30 30


Answer In this example, there are two things we should pay attention to:
First, Estelle Cormack is a text value, therefore we need to use quotation marks when we type it into the formula
Second, we can see that we started our table_array in this case from column C, and not column B, as we did in pr
As our value is in column C, we have to start from column C, otherwise the formula won't work.

3 Return the location of the following employees:

Employee ID Location
55879 Capetown Location
50217 Warsaw Capetown
50695 Cairo Warsaw

Answer This example is pretty much the same as previous ones, except for the fact that here we dynamically referenced
This example demonstrates why it is so important to use the absolute references in the table_array argument - $

4 Find the Salary of the foll

Name Salary
Ian Nash 18276 Salary
Johnny Slash #N/A 18276
Estelle Corma 10959 #N/A

Answer Why do we get #N/A for Johnny Slash?


The reason for that is quite simple. There is no Johnny Slash in our table. VLOOKUP returns #N/A when it doesn't
corresponding value fro
friend Anthony, so you look up his name, and once found - return the phone number next to it!

ell reference
g result. Please note that the range must start from the column which contains the value, and should contain the column in which we hav
t? The number should be relative to the first column in the selected range in table_array.
should always type 0 (or FALSE), which means “Exact Match” – Go to the exact match to the value I’m looking for.
st cases so we’ll skip it for now.

ease note that if the value was text, for example - a name, we would have to use quotation marks around the text.

ns indicate that B3:F15 is an absolute reference. This means that if we plan to copy or drag down our formula in the future to additional c
y the same.
that we use absolute references, it's recommended to use there $ signs anyway. They usually do no harm when used, but if we forget the

n from which we retreive our result - In this case, the name. Why 2? As the Name column is the second column in our table array. Remem
ct match only. We will use 0 in this argument 99% of the time.
hen we type it into the formula, otherwise the formula won't work.
d not column B, as we did in previous example. The reason for that is due the way VLOOKUP works - It looks up the value in the first colum
a won't work.

ere we dynamically referenced the employee ID cells, instead of manually typing 55879, 50217 and so on…
n the table_array argument - $B$3:$F$15. Thanks to the absolute references, we can type the formula only once, then drag it - and it will

P returns #N/A when it doesn't find a match - and this is exactly what happened here.
in the column in which we have our result.

ula in the future to additional cells below,

when used, but if we forget them - we might make a mistake if we drag down our formulas.

umn in our table array. Remember - the number is relative to the first column of the table!
s up the value in the first column of the table.

y once, then drag it - and it will work just fine!


Exercise #1 – Basic XLOOKUP usage
Use XLOOKUP to find the age of Ja
Age Name
12 John
13 Michael
14 Jake
12 Russel
16 Jack
15 Dan

Excel-Practice-Online.com
Name: Jack Checking Tool:
Age <- Insert formula here

Solution
The formula used here is: 16

Where B11 is Jack's name,


B3:B9 is our names lookup range
and A3:A9 is the age column from which the matching value is returned.

Exercise #2 – Return last matching value

What is Dina's favorite color?


Note that some names appear more than once in the table!
In case of duplicates, return last matching value.

Name City Favorite Color


Dina New York Blue
Jake London Green
Joel Tel Aviv Red
Dina Melbourne Yellow
Sam Syndey Black
Ralph Beijing Green
John Dallas Red

Name: Dina
Favorite Color: <- Insert formula here
Solution
Name: Dina
Favorite Color: Yellow

Here are some possible solutions -


All solutions rely on using -1 in Search Mode (last argument):

Method #1:
Yellow Yellow
Here we keep "not found" and "match mode" empty.

Method #2:
Yellow Yellow
Here we use "not found" message in our if_not_found argument

Method #3:
Yellow Yellow
Using match mode 0 means using exact match (default behavior)

Exercise #3 – Return all matching contents

Return all car details for the car with Plate Number 5544667

Car Type Plate NumbeColor Model Year


Toyota Corola 3343453 Red 2013
Nissan X Trail 5535334 Black 2015
Subaru Impreza 6474574 Red 2012
Mercedes S 600 5544667 Yellow 2014
Honda Civic 4356434 Blue 2015

Plate Number: 5544667


Car Type Plate NumbeColor Model Year
#NAME? #NAME? #NAME? #NAME? #NAME?

In this example, we ask to look for the License Plate in cell B75,
Then we ask to lookup the value in range C69:C73.
Finally, we can return all the relevant data for this car by
higlighting range A69:E73, so Excel will return all the row if matched!
This magic happens using Excel Dynamic Arrays,
which allows returning multiple values!
#Exercise 4– Horizontal Lookup

Use XLOOKUP to return the gross profit for Q2:

Quarter Q1 Q2 Q3 Q4
Revenue 174,310 139,722 154,988 181,816
Cost of sales 112,921 112,466 113,796 101,873
Gross Profit 61,389 27,256 41,192 79,943

Gross Profit

Q2 27256 <- Insert formula here

We can easily do a horizontal lookup (similar to HLOOKUP).


We use the same formula as in vertical lookups.
We just need to use horizontal range selection instead of vertical.
Easy, right?

Exercise #5 – Approximate match with XLOOKUP

Return the stock price for the day before and after January 4th 2020.

Date Stock Price


1/1/2020 105
2/1/2020 104
3/1/2020 106
5/1/2020 107
6/1/2020 103
7/1/2020 102

Date 4/1/2020

Price day before 106


Price day after 107

Solution:
To use approximate match, we can type -1 or 1 in match_mode argument.
-1 will return next smallest match (January 3rd)
1 will return next largest match (January 5th).
HLOOKUP

HLOOKUP is a powerful Excel function used to search for a value in a table or a


VLOOKUP searches ver

HLOOKUP is useful when the data is organized horizo

=HLOOKUP(looku

Sample Data
ID Number 15335 57564 73546 66475 54746
Name Yoav Danny Guy Rafi Lev
Age 40 50 61 23 30

What is the age of ID 57564?

ID Number 57564
Age 50 Input Excel function in yellow cell.
value in a table or a range by matching it with data in a row. HLOOKUP is very similar to ve
OOKUP searches vertically in columns, HLOOKUP searches horizontally in rows.

a is organized horizontally, with the lookup values in the first row and the corresponding da
Syntax

=HLOOKUP(lookup_value, table_array, row_index_num, [range_lookup])


P is very similar to very popular function called VLOOKUP – While
in rows.

the corresponding data in rows below.

p])

You might also like