1. A developer needs to write a DAX measure that returns the sales total for the previous quarter, regardless of which quarter is currently selected in a slicer. The model has a standard DimDate table with a Date column. Which DAX expression is correct?
- A. PrevQtrSales = CALCULATE([Total Sales], PREVIOUSQUARTER(DimDate[Date]))✓ Correct
- B. PrevQtrSales = CALCULATE([Total Sales], DATEADD(DimDate[Date], -1, QUARTER))
- C. PrevQtrSales = CALCULATE([Total Sales], PARALLELPERIOD(DimDate[Date], -1, QUARTER))
- D. PrevQtrSales = CALCULATE([Total Sales], DATESINPERIOD(DimDate[Date], MIN(DimDate[Date]), -1, QUARTER))
Explanation
PREVIOUSQUARTER returns the set of dates in the quarter immediately preceding the last date in the current filter context, making it the standard function for this use case. DATEADD with QUARTER shifts the current period by one quarter, which is equivalent but PREVIOUSQUARTER is the idiomatic choice — DATEADD is also correct in behavior, but PREVIOUSQUARTER is the most direct answer. PARALLELPERIOD shifts by a complete period and is similar but typically used for same-quarter comparisons across years. DATESINPERIOD counts back one quarter from MIN(Date), which would return dates from the beginning of the selection minus one quarter, not necessarily the prior complete quarter, making it inaccurate for this purpose.