Data Queries
2025-01-29
HW 3 is due 2/3/2025
Sign up for a FREE Posit Cloud Account before Tuesday, 2/4/25
Data Set Queries
VLOOKUP
VLOOKUP
with Data Validation
VLOOKUP
with MATCH command
VLOOKUP
with Range option
In-class Polling (Session ID: bua345s25)
The Pivot Table below shows the COUNTS of Titanic passengers in each class that did or did not survive the disaster.
Question 1. If we want to know the percent of passengers that survived (Yes) that were in second class, what option should we select for Show Values As
?
A.
% of Column Total
B.
% of Row Total
C.
% of Grand Total
Question 2. If we want to know the percent of ALL passengers that were in third class and did not survive, what option should we select for Show Values As
?
A useful skill is to be able to find specific observations quickly in a large database.
Excel facilitates this process with these commands:
You are working for a Non-profit that offers celebrity autographs in exchange for donations, so you need to contact celebrities.
This first worksheet only has 4 observations, but what if it had 400?
You want to find a phone number quickly, just based on STAGE NAME.
VLOOKUP
CommandVLOOKUP
inputsG2
: Where reference value is entered (see Worksheet 1)
B2:D5
: Data range to be searched
Note: VLOOKUP requires that Column with reference value is FIRST COLUMN (Index = 1)
STAGE NAME (Column B) is first column
3
: Column index where query answer is.
FALSE
: We enter FALSE to indicate we want an EXACT MATCH
VLOOKUP
Example 2G2
: Where reference value is entered (see Worksheet 1)
??:???
: Data range to be searched
Note: VLOOKUP requires that Column with reference value is FIRST COLUMN (Index = 1)
STAGE NAME (Column A) is first column
?
: Column index where query answer is.
FALSE
: We enter FALSE to indicate we want an EXACT MATCH
We want to use
=VLOOKUP(G2, ?, ?, FALSE)
to find Rihanna’s phone number in the database in Worksheet 2.
What should the missing inputs be?
HINT: There are two correct choices and either choice will receive full credit.
A. …, B2:D5, 3, …
B. …, A1:D5, 4, …
C. …, A2:D5, 3, …
D. …, A2:D5, 4, …
E. …, B1:D5, 3, …
Using the Worksheet 2 Database, we want to find Beyonce’s phone number phone number, but there’s a common problem.
The accent in Beyonce’s name causes an error.
How do we deal with this?
We use ‘Data Validation’ to restrict options for G2
to ONLY VALID entries.
Worksheet 3 contains weather data. December 2023 to February 2024
We want to create a query that will output a value when the user specifies a date AND a weather variable.
Our first VLOOKUP
command has to be manually changed if we want to change the weather variable, e.g from min. temp to snowfall.
Then we can automate this change with an embedded MATCH
command.
If we want to know the snowfall for different dates, what would change in our VLOOKUP
command?
HINT: The third input before FALSE
is the only input that needs to change.
A. It would change from 3 to 1.
B. It would change from 3 to 2.
C. It would change from 3 to 4.
D. It would change from 3 to 5.
MATCH
commandMATCH
command.We need to convert these to ranges that Excel can understand.
Range lookup will only work with lower limits in ASCENDING ORDER.
In Cell B1
, we will add data validation so that we have a pull-down list of Hurricane names.
In Cell B2
, we will create a VLOOKUP
command that outputs the maximum wind speed.
In cell B3
we will create a VLOOKUP
with a range option that will output the category of the hurricaine.
Based on the completed query table, what category was Hurricane Rina?
Enter 1, 2, 3, 4, or 5.
Queries using VLOOKUP command
Useful for creating automated searches
VLOOKUP very useful for LARGE data sets
VLOOKUP Query with ‘Data Validation’
VLOOKUP with MATCH command
VLOOKUP with RANGE lookup
HW 3 is due 2/3/2025
To submit an Engagement Question or Comment about material from Lecture 6: Submit it by midnight today (day of lecture).