Lab_4___Data_Analysis_Expressions
Lab_4___Data_Analysis_Expressions
Dr Huan Vu
Business AI Lab
1
Faculty of Data Science and Artificial Intelligence, NEU
Prerequisites
To be able to complete this Lab, you should have finished Lab 2 and 3. You should have imported all
related data to the Adventure Works project and built a data model based on them.
Objectives
Data Analysis Expressions, commonly known as DAX is the formula language that drives the Power
BI front-end.
1. We have created a column named QuantityType in the Sales Data table, using Power Query
in Lab 2. Remove that column and create the same calculated column, this time using DAX.
Reminder: The QuantityType is Single Item if the order quantity is 1. If the order quantity
is more than 1, the QuantityType is Multiple Items.
2. Create an additional column in the Sales Data column, which represents the SUM over all
OrderQuantity of all sales. Does it make sense to do that? If not, remove the column.
2 DAX measures
Measures are DAX formulas used to generate new calculated values. Measures are based on filter
context.
1. Recreate the Sum of Order Quantity as an Explicit measure named Quantity Sold.
2. Create an Explicit measure named Quantity Returned to calculate the Sum of all ReturnQuan-
tity.
3. Create an Explicit measure named Averate Retail Price by Averaging over ProductPrice
in the Product Lookup table.
4. Create an Explicit measure named Total Returns that counts the number of return transac-
tions. Compare Total Returns and Quantity Returns and find out why they are different.
5. Create an Explicit measure named Total Orders that counts the amount of Orders placed.
Make sure that the computation is correct.
6. Create an Explicit measure named Total Customers to calculate the number of distinct cus-
tomers who made a transaction.
7. Create an Explicit measure named Return Rate, defined as quantity returned divided by
quantity sold.
3 Measure tables
It’s a common best practice to create a dedicated table to store your measures. Let’s take a look at how
to do it. Make sure you finished creating this table to stay organized.
@BAI Lab 2