Analyzing and Visualizing Data with Microsoft Power BI — Question 11
You have a Power BI model that contains the following two tables:
✑ Sales (Sales_ID, DateID, sales_amount)
✑ Date(DateID, Date, Month, Week, Year)
The tables have a relationship.
You need to create a measure to calculate the sales for same period from the previous year.
Which DAX formula should you use?
Answer options
- A. SUM(sales[sales_amount]) - CALCULATE(SUM(sales[sales_amount]), DATESYID('Date'[Date]))
- B. CALCULATE(SUM(sales[sales_amount]), SAMEPERIODLASTYEAR('Date'[Date]))
- C. SUM(sales[sales_amount]) "" CALCULATE(SUM(sales[sales_amount]), SAMEPERIODLASTYEAR('Date'[Date]))
- D. CALCULATEx(SUM(sales(sales_amount]), DATESYID('Date'[Date]))
Correct answer: C
Explanation
Option C is the correct choice as it uses the SAMEPERIODLASTYEAR function properly to retrieve sales data from the previous year. Option A contains an incorrect function 'DATESYID', which is not valid. Option B is incorrect because it does not match the syntax of the question. Option D also includes a typo with 'CALCULATEx' and an invalid use of 'DATESYID'.