PL-300 · Question #63
You have a Power BI model for sales data. You create a measure to calculate the year-to-date sales. You need to compare the year-to-date sales with the previous year for the same time period. Which…
The correct answer is C. SAMEPERIODLASTYEAR. To compare year-to-date sales with the same time period in the previous year, the DAX function SAMEPERIODLASTYEAR should be used.
Question
You have a Power BI model for sales data. You create a measure to calculate the year-to-date sales. You need to compare the year-to-date sales with the previous year for the same time period. Which DAX function should you use?
Options
- ALASTDATE
- BTOTALYTD
- CSAMEPERIODLASTYEAR
- DPREVIOUSYEAR
How the community answered
(41 responses)- A17% (7)
- B7% (3)
- C71% (29)
- D5% (2)
Why each option
To compare year-to-date sales with the same time period in the previous year, the DAX function SAMEPERIODLASTYEAR should be used.
LASTDATE returns the last date in the current filter context, which is not suitable for comparing periods across years.
TOTALYTD calculates the year-to-date total for the current year but does not provide a mechanism to directly compare it to a previous year's equivalent period without further functions.
The SAMEPERIODLASTYEAR DAX function calculates a set of dates that are one year prior to the dates in the current filter context, preserving the day and month. This precisely enables comparing a current year-to-date period with the equivalent period from the previous year.
PREVIOUSYEAR returns all dates of the prior year, not specifically the same period or duration as the current filter context, making it less precise for a 'same period last year' comparison than SAMEPERIODLASTYEAR.
Concept tested: DAX time intelligence (SAMEPERIODLASTYEAR)
Source: https://learn.microsoft.com/en-us/dax/sameperiodlastyear-function-dax
Topics
Community Discussion
No community discussion yet for this question.