Microsoft Certified: Power BI Data Analyst AssociateModel the dataEasy
A data modeler is optimizing a Power BI model. The model contains a 'Sales' table with 'SaleAmount' and 'DateKey'. There is also a 'Date' dimension table with 'DateKey', 'CalendarYear', and 'MonthName'. The relationship between 'Sales' and 'Date' is active. The modeler needs to calculate the total sales for the previous year. Which DAX function is specifically designed for this type of time intelligence calculation?
- APARALLELPERIOD
- BDATEADD
- CSAMEPERIODLASTYEAR
- DPREVIOUSYEAR
Show answer & explanationAnswer & explanation
Correct answer: D. PREVIOUSYEAR
PREVIOUSYEAR is a time intelligence function that returns a table that contains all dates from the previous year, based on the first date in the current filter context.
Why the other options are wrong
- A. PARALLELPERIOD returns a set of dates parallel to the given period, but shifted by a specified number of intervals.
- B. DATEADD shifts a given set of dates by a specified interval (e.g., -1 year), but PREVIOUSYEAR is more direct for the entire prior year.
- C. SAMEPERIODLASTYEAR shifts a period (like a month or quarter) to the same period in the previous year, not necessarily the entire previous year.
PREVIOUSYEAR Function
PREVIOUSYEAR is a DAX time intelligence function that returns a table that contains all dates from the previous year, given the current date context.
- Returns a full year of dates.
- Works relative to the last date in the current filter context.
- Commonly used to calculate year-over-year comparisons.
- Must be used within CALCULATE to modify the filter context of a measure.
Memory trick: Time intelligence functions are your calendar's superpowers.