0% found this document useful (0 votes)
29 views

Ch-3 Lookup Functions

Uploaded by

edieali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Ch-3 Lookup Functions

Uploaded by

edieali
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

CHAPTER 3

Lookup functions

Way to study:
Step 1: Read the problems of the chapter with input data.
Step 2: Find out the domain area of each problem.
Step 3: If it’s a new area, learn at first main business domain knowledge and KPIs of that area
from other sources like GPT and from this book.
Step 4: Find out and learn and note any new knowledge of MS-Excel required (from this book or
any other sources like Bakaly’s videos) here or in its Excel (core) folder.
Step 5: Output / solution of the problem.
Step 6: The same goes for the Exercise questions except that you need to do step 4 completely
by your own.

VLOOKUP:
 Definition:
It’s a searching function for a specific value of a column in a range of cells/table corresponding to
a “specific value” of another column in the same range of cells/table. And we use lookup
function (means typing the VLOOKUP formula) outside the range of cells where we have to
search. And that “specific value” in another cell of that outside area is also mentioned as first
argument of VLOOKUP function.
That outside area can be in the same sheet or another sheet.
And that cell (where we are typing VLOOKUP function) can be extended using relative/partial
referencing to entire column.
 Example:
o Suppose we have this range of cells/table in sheet “Item List”. Concentrate what data is given:
o And we have another sheet “VLOOKUP(Exact)-2”.

o Now here, in VLOOKUP(Exact)-2 sheet, for a specific item no. given in column “Item No.”, we
want to fill the matching Description in the column “Description”. So, for this purpose, we will
have to refer the sheet “Item List”, in which description is given for all Item Nos.
o Therefore, we will search in the related range of cells of sheet “Item No.”, the required data
(Description) for sheet “VLOOKUP(Exaxt)-2” corresponding a specific value (Item No.) given in
same “VLOOKUP(Exaxt)-2” sheet“.
o But there is a limitation! Note that we have to select the range of cells of the sheet
where we are searching (i.e. Item List) in such a way that the first column must be the
given value (i.e. Item No.).
o VLOOKUP stands for "Vertical Lookup." It's called vertical because it searches for a value in the
first column of a table array and retrieves a corresponding value in the same row from another
column. The search is vertical along a column.

If you use VLOOKUP to find the price of a Banana, it looks vertically in the "Fruit" column, finds
"Banana," and returns the corresponding value from the "Price" column, which is $0.75.
Syntax:
The syntax of the VLOOKUP function is as follows. The brackets ([ ]) indicate optional arguments:

VLOOKUP(lookup value,table range,column index,[range lookup])

o “Lookup value” is the value that you want to look up in the first column of the range of cells /
table range.
In our example, it is the C5 of sheet “VLOOKUP(Exaxt)-2”
o “Table range” is the range that contains the entire lookup table. The table range includes the
first column, in which you try to match the lookup value, and any other columns in which you
want to look up formula results.
Note here, we used the word “columns” because sometimes the column from which the
value is to be obtained isn’t adjacent to the lookup column. For instance, if we were searching
for Unit price then it is not the adjacent column of Item No. column and another reason you
can observe in example 2 that will be given later on.
In our example, it is B3:C12 of the sheet “Item List”. Note we have not selected the column
headings of this table range. Also note that column B is the 1st column, which is a must
requirement.
o “Column index” (starting from number 1) is the column number in the table range from which
the value of the lookup function is obtained.
In our example it is 2 (column C) of sheet “Item List”.
o Range lookup is an optional argument. The point of range lookup is to allow you to specify an
“Exact or approximate” match. If the range lookup argument is True or “omitted”, the first
column of the table range must be in “ascending” numerical order. It means the default
Range lookup argument is true. Mostly you want exact match but in some cases where there
is less than or greater than situation, approximate option is used. See further example later
on.
Now there are following rules in this regard:
 If the range lookup argument is True or omitted and an exact match for the lookup value is
found in the first column of the table range, Excel bases the lookup on the row of the table
in which the exact match is found.
 If the range lookup argument is True or omitted and an exact match does not exist, Excel
bases the lookup on the largest value in the first column that is less than the lookup value.
 If the range lookup argument is False and an exact match for the lookup value is found in
the first column of the table range, Excel bases the lookup on the row of the table in which
the exact match is found.
 If no exact match is obtained, Excel returns an #N/A (Not Available) response.
In our example, we are using FALSE to make it exact match.
So, in our example, complete formula is:
=vlookup(C5,’Item List’!B3:C12,2,FALSE)
Same formula can be dragged for other cells in the same column.
Similarly, if we are searching for Unit Price the formula would be:
=vlookup(C5,’Item List’!B3:D12,3,FALSE)
Further Examples:
VLOOKUP with string data using approximate match:
VLOOKUP with approximate match is typically used with numerical data where you're
looking for a value within a range. However, with string data, you can still find
approximate matches in certain scenarios. One common application is when you have
sorted string data and want to find the closest match.

VLOOKUP with “numerical data in group” using approximate match:


For answer see WM: 13 of this tutorial or answer of first question of chapter 3 of book.
VLOOKUP for 2-Dimensional searching using Match function
OR
VLOOKUP when you don’t know the index of the column to search for using Match
function
In a two-dimensional search with VLOOKUP, you're looking for a value in a table that has both
rows and columns. Let's consider a simple example with student grades:

Example 1:
Suppose you have a table with student names in the first column (A), subjects in the first row (B
to D), and corresponding grades at the intersection of each student and subject. Your table might
look like this:

| A | B | C | D |

|--------------- |------------ |------------ |------------ |

| Student | Math | English | Science |

|--------------- |------------ |------------ |------------ |

| John | A | B | A |

| Mary | B | A | C |

| Bob | C | B | A |

Now, let's say you want to find Mary's grade in English. You can use the VLOOKUP
function for this two-dimensional search:
=VLOOKUP("Mary", A2:D4, MATCH("English", B1:D1, 0) + 1, FALSE)

Breaking it down:

 "Mary" is the lookup value (the student's name).

 A2:D4 is the table range.

 MATCH("English", B1:D1, 0) + 1 finds the column index for "English" and adds 1 to get
the correct column in the table. We need to add 1 because the index returned by the
MATCH function represents the relative position of an item in a range i.e. it will not
count Student Name column. Also note that 0 is an optional argument which is called as
[match_type] that specifies the type of match: 1 for less than, 0 for an exact match, and
-1 for greater than.

Syntax of Match function


=MATCH(lookup_value, lookup_array, [match_type])

 lookup_value: The value you want to find.

 lookup_array: The range of cells containing possible matches.

 [match_type]: An optional argument that specifies the type of match: 1 for less
than, 0 for an exact match, and -1 for greater than.

The MATCH function returns the relative position of the lookup_value within the
lookup_array. The first item in the range is considered to be in the 1st position.

For further details of Match function see chapter 5.

 FALSE is used for an exact match.

This formula will return Mary's grade in English, which is "A" in this case. The MATCH function is
used to dynamically determine the column index based on the subject you're looking for.

Example 2:
In Chapter 12, “IF, IFERROR, IFS, CHOOSE, and SWITCH functions,” you will learn how to use the
IFERROR function to eliminate #N/A responses. Note that a range lookup argument of 1 is
equivalent to True, whereas a range lookup argument of 0 is equivalent to False.

HLOOKUP:
Definition:
The HLOOKUP function in Excel is used to look up a value in the first row of a table or range and
return a corresponding value from another row.

Example:
Let's consider a simple example where you have a table with product names in the first row
(B1:E1) and corresponding prices in the second row (B2:E2):

| | A | B | C | D | E |

|------ |------ |------ |------ |------ |------ |

| 1 | | Apple | Banana | Orange | Grape |

| 2 |Price | 1.00 | 0.75 | 1.20 | 1.50 |

Now, suppose you want to find the price of an orange. You can use HLOOKUP:

=HLOOKUP("Orange", B1:E2, 2, FALSE)

Breaking it down:

 "Orange" is the lookup value (the product you want to find).

 B1:E2 is the table array.

 2 is the row index number, indicating we want to retrieve the value from the second row of
the table (where the prices are).

 FALSE is used for an exact match.

This formula will return the price of an orange, which is 1.20 in this case.
Syntax:

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

 lookup_value: The value to be found in the first row of the table.

 table_array: The range of cells containing the data.

 row_index_num: The row number in the table from which to retrieve the value.

 [range_lookup]: An optional argument that indicates whether to find an exact match


(FALSE) or an approximate match (TRUE or omitted).

Another difference between VLOOKUP and HLOOKUP:


it is not necessary to have the data sorted when using the HLOOKUP function in Excel. Unlike VLOOKUP,
which requires the data to be sorted in ascending order for approximate matches, HLOOKUP performs a
direct lookup in the first row of the specified range without the need for sorting.

You can use HLOOKUP with both sorted and unsorted data. The function searches for the specified value
in the first row of the table array and returns the corresponding value from the specified row.

Further Example:
WM # 13: VLOOKUP with data levels / grouped data:
Step 1: Problem with input data:
How do I write a formula to compute tax rates based on income?

Suppose that the tax rate depends on income, as shown in the following table:

Income level Tax rate


$0–$9,999 15%

$10,000–$29,999 30%

$30,000–$99,999 34%

$100,000 and over 40%

Step 2: Domain: Payroll management


Step 3: Related domain knowledge / KPIs:
Step 4: Excel Knowledge required / gained:
The following example shows how a VLOOKUP function works when the first column of the table range
consists of numbers in ascending order.

To see an example of how to write a formula that computes the tax rate for any income level, open the
file Lookup.xlsx, shown in above data Figure.

I began by entering the relevant information (tax rates and break points(Tax rates)) in cell range D6:E9. I
named the table range D6:E9 lookup. I recommend that you always name the cells you’re using as the
table range. If you do so, you need not remember the exact location of the table range, and when you
copy any formula involving a lookup function, the lookup range will always be correct.

To illustrate how the lookup function works, I entered some incomes in the range D13:D17. By copying
from E13:E17 the formula VLOOKUP(D13,Lookup,2,True),

I computed the tax rate for the income levels listed in D13:D17.
Note in D13, the income of –$1,000 yields #N/A because –$1,000 is less than the lowest income level in
the first column of the table range. If you want a tax rate of 15 percent associated with an income of –
$1,000, simply replace the 0 in D6 by a number that is –1,000 or smaller.

In F13:F17, I changed the value of the range lookup argument from True to False and copied from F13 to
F14:F17 the formula VLOOKUP(D13,Lookup,2,False). Cell F14 still yields a 34 percent tax rate because the
first column of the table range contains an exact match to $30,000. All the other entries in F13:F17
display #N/A because none of the other incomes in D13:D17 have an exact match in the first column of
the table range. In Chapter 12, you will learn how to ensure that Excel does not return the #N/A error in
these situations.

Step 5: Output / solution of the problem:


WM # 14:
Step 1: Problem with input data:
Suppose that a product’s price changes over time. I know the date the product was sold. How can I write
a formula to compute the product’s price?

Step 2: Domain: Inventory Management


Step 3: Related domain knowledge / KPIs:
Step 4: Excel Knowledge required / gained:
Step 5: Output / solution of the problem:
All are easy.
Solution:
The domain of this problem is “interpolation of interest rate for any
period between 2 different periods(years)”
1. Business modeling:
Interpolation is a method of estimating values that fall between known
values. In simpler terms, it's like making an educated guess about values
that are not explicitly given in a set of data points.
And keep in mind you are not supposed to solve this type of problem
logically without prior knowledge of the formula for this type of problem.
So it’s just a matter of finding / searching the right formula (business
modeling) and then do the worksheet modeling (in this case using
VLOOKUP function)
So by searching the formula for interpolating the annual interest rate for
any two periods between 2 different years on chatgpt, we found:
The formula for interpolating the annual interest rate for any period
between two different years is:
2. Now the worksheet modeling:
So, let’s create the structure of worksheet for this problem:
Writer has done it in his own way. I did it “my way”. See the solution file for both. I took
help from chatgpt to calculate intermediate values for main interpolation formula.
Solution:
Answer should look like this:
Business modelling:
As a first step, let’s do it for only one cell. It means from new York to boston:
CHAPTER 4
The INDEX function

Syntax of the INDEX function The INDEX function allows you to return the entry in any row and
column within an array of numbers. The most commonly used syntax for the INDEX function is the
following: INDEX(Array,Row Number,Column Number) To illustrate, the formula INDEX(A1:D12,2,3)
returns the entry in the second row and third column of the array A1:D12. This entry is the one in
cell C2.
1. WM # 6: Range names
Step 1: Problem with input data:

Step 2: Domain:
Step 3: Related domain knowledge / KPIs:
Step 4: Excel Knowledge required / gained:
How can I create named ranges?
Step 5: Output / solution of the problem:
2. WM # 6: Range names
Step 1: Problem with input data:

Step 2: Domain:
Step 3: Related domain knowledge / KPIs:
Step 4: Excel Knowledge required / gained:
How can I create named ranges?
Step 5: Output / solution of the problem:
3. WM # 6: Range names
Step 1: Problem with input data:

Step 2: Domain:
Step 3: Related domain knowledge / KPIs:
Step 4: Excel Knowledge required / gained:
How can I create named ranges?
Step 5: Output / solution of the problem:
4. WM # 6: Range names
Step 1: Problem with input data:

Step 2: Domain:
Step 3: Related domain knowledge / KPIs:
Step 4: Excel Knowledge required / gained:
How can I create named ranges?
Step 5: Output / solution of the problem:

You might also like