Analyzing and Visualizing Data with Microsoft Power BI — Question 4
You have a Power BI model that contains the following tables:
✑ Sales (Sales_ID, DateID, sales_amount)
✑ Date (DateID, Date, Month, week, Year)
The tables have a relationship. Date is marked as a date table in the Power BI model.
You need to create a measure to calculate the sales for the last 12 months.
Which DAX formula should you use?
Answer options
- A. CALCULATEx(SUM(sales[sales_amount]) DATESYTD (‘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. SUM(sales[sales_amount])-CALCULATE(SUM(sales[sales_amount]),DATESYTD(‘Date’[Date]))
Correct answer: C
Explanation
The correct answer is C because it calculates the total sales and subtracts the sales from the same period last year, effectively giving the sales for the last 12 months. Option A incorrectly uses DATESYTD, which is not suitable for a 12-month calculation. Option B only focuses on the sales from the same period last year, and Option D also uses DATESYTD, which does not achieve the desired 12-month sales figure.