You are on page 1of 7

HOMEWORK: Power Pivot & DAX 101

Using the FoodMart_Data_Model workbook, complete the following steps (Answers below - no
peeking!)

1) In the Store_Lookup table, create a new calculated column named days_since_opening to


calculate the number of days since the store opened (hint: use the TODAY() function and reference
the first_opened_date column)

● Format as a whole number, with a thousands separator (Data Type: Decimal Number,
Format: Whole number)
● Which store opened first? Which opened most recently?

2) Update the formula in #1 to calculate the number of days since the last remodel date, rather than
the store opening date, and rename the column days_since_remodel.

● Which store was remodeled most recently?

3) In the PivotTable view, create a new measure assigned to the Returns table named [Quantity
Returned], which sums the quantity column from the Returns data table (format as whole number,
with thousands separator)

● Update the PivotTable layout to show Quantity Returned by store_country as row labels.
What was the total quantity of returned products from stores in Canada?
● Pull product_brand into the pivot as additional row labels. What was the total quantity of
"Best Choice" products returned in stores from Mexico?
● Replace product_brand with yearly_income from the Customer_Lookup table. What do
you notice about the Quantity Returned values? Why is that happening?

4) Update the PivotTable layout to just show Quantity Returned by product_brand (as row labels),
and add a filter for store_country = Canada

● You should see a Quantity Returned value of 3 for "Black Tie" products in Canada
● Replicate each step of the measure calculation for that cell by actually filtering the related
tables in the data model, and confirm that the value shown in the Data View calculation
pane matches the pivot

ANSWERS:

1a) Refer to FoodMart_SOLUTION_FILE workbook in the course resources


1b) Store #22 (Walla Walla, WA) opened first, Store #4 (Camacho, Zacatecas) opened most
recently

2a) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

2b) Store #13 (Salem, OR)

3) SUM(Returns[quantity])

3a) 541

3b) 39

3c) The Quantity Returned measure returns repeating values for every row, because there is no
relationship between the Returns data table and the Customer_Lookup table

4) N/A

HOMEWORK: Math & Stats Functions

Using the FoodMart_Data_Model workbook, complete the following steps (Answers below - no
peeking!)

1) Create new measures to calculate the maximum product_retail_price ([Max Retail Price]) and the
minimum product_retail_price ([Min Retail Price]), assign both measures to the Product_Lookup
table, and format as currency with two decimal places.

● Which tables in the model are "legal" to pull into the pivot when you're analyzing these
measures as values?
● Pull in product_brand as row labels. What's the maximum retail price for "Green Ribbon"
products?

2) Create a new measure to calculate the average customer_age ([Average Age]), assign to the
Customer_Lookup table, and format as a decimal number with one decimal place.

● Update your PivotTable layout to show customer_city on rows. What’s the average age
of customers who live in Imperial Beach?

3) Create a new measure to calculate the total number of customers ([Total Customers]) based on
the number of rows in the Customer_Lookup table, and format as a whole number with a thousands
separator.

● Pull gender into rows. How many female customers overall? Male customers?
4) Create a new measure to calculate the number of unique cities ([Unique Cities]) based on the
customer_city field in the Customer_Lookup table, and format as a whole number with a thousands
separator.

● Pull customer_country into rows. How many unique customer cities are represented by
customers from Mexico? From the USA?

ANSWERS:

1) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

1a) Any connected and downstream tables: Transactions, Returns, and Product_Lookup

1b) $3.11

2) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

2a) 70.8 (Note: Since age is based on the TODAY() function, this value will change over time)

3) 5,097 female customers and 5,184 male customers

4) 13 unique cities from customers in Mexico, 78 unique cities from customers in USA

HOMEWORK: Logical & Text Functions

Using the FoodMart_Data_Model workbook, complete the following steps (Answers below - no
peeking!)

1) Create a calculated column in the Store_Lookup table named supermarket_size to categorize the
size of each supermarket in the table, based on the following logic:

● If total_sqft > 30,000 then supermarket_size = "Large"


● Otherwise supermarket_size = "Small".

2) Create a calculated column in the Customer_Lookup table named membership_level, based on


the following logic:

● If member_card = "Golden", "Silver" or "Bronze", then membership_level = "Premium"


● Otherwise membership_level = "Basic"
3) Update the supermarket_size calculation in the Store_Lookup table, to reflect the following logic:

● If total_sqft > 35,000 then supermarket_size = "Huge"


● If total_sqft > 30,000 and total_sqft <=35,000, then supermarket_size = "Large"
● If total_sqft > 25,000 and total_sqft <=30,000, then supermarket_size = "Medium"
● If total_sqft <= 25,000 then supermarket_size = "Small"
● Otherwise supermarket_size = "Other"

4) Create a calculated column in the Store_Lookup table named store_street_num to extract the
street number from the store_street_address column

ANSWERS:

1) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

2) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

3) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

4) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

HOMEWORK: CALCULATE, FILTER & ALL

Using the FoodMart_Data_Model workbook, complete the following steps (Answers below - no
peeking!)

1) Use CALCULATE to create a new measure that evaluates the total quantity of Low-Fat products
sold ([Low-Fat Quantity Sold]). What was the total Low-Fat quantity sold for "High Top" product
brand products?

2) Use CALCULATE and ALL to create a new measure that always returns the overall total quantity
([Overall Total Quantity])

● Divide [Low-Fat Quantity Sold] by [Overall Total Quantity] to calculate a new measure
named [Low-Fat Sales %]
● Update your PivotTable layout to show [Low-Fat Sales %] by customer_country. In which
country do customers purchase low fat products most often? Least often?
3) Create a new Excel table named Age_Threshold in a new worksheet, with a column header
named Age_Threshold and the following row values: 50, 60, 70, 80, 90, 100.

● Load the table to the data model, but leave it disconnected from other tables
● Drag Age_Threshold into a PivotTable as a slicer
● Create a new measure to "harvest" the minimum slicer value selected ([Minimum Age])
● Pull [Minimum Age] into the pivot and confirm that the values update with each slicer
selection
● Create a new measure to calculate the total transactions for customers older than the
selected threshold ([Trans Above Age Threshold])

4) Update your PivotTable layout to show [Minimum Age] and [Trans Above Age Threshold] on
values, with customer_city on rows.

● Add conditional formatting to bring the transaction values to life -- your choice!
● How many transactions were there in Coronado among customers above the age
threshold of 80? How about in Royal Oak, among customers older than 100?

ANSWERS:

1) 10,635

2a) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

2b) USA (23.73%), Canada (2.07%)

3) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

4a) N/A

4b) 525 customers over the age of 80 in Coronado, 20 customers over the age of 100 in Royal Oak
(Note: Since age is defined using the TODAY() function, these values will change over time)

HOMEWORK: Iterator Functions

Using the FoodMart_Data_Model workbook, complete the following steps (Answers below - no
peeking!)

1) Use SUMX and RELATED to calculate a new measure named [Total Cost], equal to quantity from
the Transactions table multiplied by product_cost from the Product_Lookup table. Format as
currency, rounded to the nearest dollar.
● Update your PivotTable view to show [Total Cost] by product_brand. What was the total
cost of Tri-State products sold?

2) Create a new measure named [Profit], equal to [Total Revenue] minus [Total Cost].

● Update your PivotTable view to show [Profit] by sales_district from the Region_Lookup
table, then sort sales_district descending by Profit. Which district saw the highest total
profit? The lowest?

3) Use RANKX to calculate the rank of each product brand, by profit ([Product Brand Rank (by
Profit)]) (Hint: you will need to specifically reference the product_brand column in the ALL function)

● Update your PivotTable view to show [Product Brand Rank (by Profit)] with
product_brand on rows, sorted descending. Which brand drove the most overall profit?
Which is ranked #25?

ANSWERS:

1) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

1b) $20,283

2) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

2b) Los Angeles ($124,978), Guadalajara ($2,936)

3) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

3b) Hermanos ($33,167), Bravo ($16,322)

HOMEWORK: Time Intelligence

Using the FoodMart_Data_Model workbook, complete the following steps (Answers below - no
peeking!)

1) Create the following time intelligence measures:

● [YTD Profit]
● [QTD Profit]
● [MTD Profit]
● [Last Month Profit]
● [MoM Profit % Change]
● [6-Month Rolling Profit]
● [30-Day Rolling Profit]
● [30-Day Profit Avg]

2) Create a PivotTable view showing 1998 dates, with date on rows. use this view to explore each
time intelligence calculations and confirm accuracy.

ANSWERS:

1) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

2) Refer to FoodMart_SOLUTION_FILE workbook in the course resources

You might also like