PL-300 · Question #370
You have a Power BI model that contains the following data. The Date table relates to the Sales table by using the Date columns. The model contains the following DAX measure. Total Sales = SUM(Sales[S
The correct answer is A. CALCULATE ( [Total Sales], DATEADD (Date[Date], -1, QUARTER ) ). To calculate a measure for a previous quarter, the DAX CALCULATE function combined with DATEADD is used to shift the filter context by a specified period.
Question
You have a Power BI model that contains the following data. The Date table relates to the Sales table by using the Date columns. The model contains the following DAX measure. Total Sales = SUM(Sales[Sale]) You need to create another measure named Previous Quarter to display the sales one quarter before the selected period. Which DAX calculation should you use?
Exhibit
Options
- ACALCULATE ( [Total Sales], DATEADD (Date[Date], -1, QUARTER ) )
- BCALCULATE ( [Total Sales], DATESQTD (Date[Date] ) )
- CTOTALQTD ( [Total Sales], Date[Date] )
- DCALCULATE ( [Total Sales], PARALLELPERIOD (Date[Date], 1, QUARTER ) )
How the community answered
(45 responses)- A80% (36)
- B7% (3)
- C11% (5)
- D2% (1)
Why each option
To calculate a measure for a previous quarter, the DAX CALCULATE function combined with DATEADD is used to shift the filter context by a specified period.
The `CALCULATE` function modifies the filter context for the `[Total Sales]` measure, and `DATEADD(Date[Date], -1, QUARTER)` shifts the current date context back by one quarter, effectively calculating sales for the previous quarter.
`DATESQTD` calculates Quarter-To-Date values, not values for a previous quarter.
`TOTALQTD` calculates Quarter-To-Date values, not values for a previous quarter.
`PARALLELPERIOD(Date[Date], 1, QUARTER)` would calculate sales for the *next* quarter because the second argument is a positive '1' interval; for the previous quarter, it should be -1.
Concept tested: DAX time intelligence functions
Source: https://learn.microsoft.com/en-us/dax/dateadd-function-dax
Community Discussion
No community discussion yet for this question.
