03 Referencing and Lookups
03 Referencing and Lookups
WELCOME TO GA
GENERAL ASSEMBLY
Our Learning Goals
Wrangle/Prepare:
Clean and prepare
relevant data.
Analyze: Structure,
comprehend, and
visualize data.
While we’re still investigating the reason behind the increase in returns, let’s
open up all of your Superstore files and look into those attributes you think will
have the biggest impact on returns.
WELCOME TO GA
GENERAL ASSEMBLY
Referencing and VLOOKUP
VLOOKUP is:
Alternatively, click fx
in the menu ribbon
and select Function >
VLOOKUP.
Let’s combine data from another worksheet into the Superstore data set and
explore the concept of a “lookup table” as well as how to use one to categorize
our quantitative data.
Now, we’ll examine if certain states have more returns than others.
1. In our “Returns” worksheet, go to Column C.
2. Name this “state” by typing this in Cell C1.
3. In Cell C2, enter:
=VLOOKUP(A2,orders!A:V,23,FALSE)
4. Expand this formula to all rows by double clicking the bottom-right corner
of the cell.
Now we have the states in our “Returns” data set!
Now let’s say we want to bring in more information from the “Orders” data set.
We don’t need everything, just a few columns.
On your own, use VLOOKUP to bring the “category,” “sales,” and “profit”
columns from the “Orders” workbook to the “Returns” workbook.
Category:
=VLOOKUP(A2,orders!A:J,10,FALSE)
Sales:
=VLOOKUP(A2,orders!A:N,14,FALSE)
Profit:
=VLOOKUP(A2,orders!A:O,15,FALSE)
WELCOME TO GA
GENERAL ASSEMBLY
What Are Categorical Variables?
A categorical value, aka, a nominal variable, typically has two or more non-
ordinal categories (values).
2. In Cells A1, A2, and A3, enter values -5, 0, and 0.3.
3. In Cells B1, B2, and B3, enter values low, medium, and high.
4. On the original worksheet (in the “Returns” workbook), type “Margin Category” in Cell H1.
Other LOOKUPs
WELCOME TO GA
GENERAL ASSEMBLY
What Is HLOOKUP?
● These LOOKUPs are unidirectional and must work with indicies fixed to
the left side (VLOOKUP) or top (HLOOKUP) of the work area.
● Because the VLOOKUP references a col_index, it’s unable to dynamically
update whenever you insert a column or columns in the table_array.
Let’s see what happens when we “break” the VLOOKUP by inserting a column.
XLOOKUP
WELCOME TO GA
GENERAL ASSEMBLY
What Is XLOOKUP?
“If not found” XLOOKUP allows us to set a return value if a match isn’t found,
negating the use of “IFERROR” or “IFNA.”
WELCOME TO GA
GENERAL ASSEMBLY
INDEX
Wrapping Up
WELCOME TO GA
GENERAL ASSEMBLY
Recap Looking Ahead
Today, we...
Up Next: Aggregating Data With
● Built relationships between PivotTables
cells in Excel.
● Manipulated data sets using
VLOOKUP.
● Looked up values in other
tables using INDEX and
MATCH.