PREVIOUSMONTH vs DATEADD for Previous Month Sales in DAX
You have a Power BI data model with a 'Date' table that contains continuous dates from January 1, 2020, to December 31, 2025. The 'Sales' table has a relationship with the 'Date' table. You need to create a measure that calculates the total sales for the last 12 months from the current context. Which DAX function should you use?
⚠ Common exam trap
Many exam-takers confuse SAMEPERIODLASTYEAR (which compares a fixed prior period) with a rolling 12-month calculation, not realizing that DATESINPERIOD is the correct function for a dynamic trailing window.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
DATESINPERIOD
The DATESINPERIOD function is correct because it returns a contiguous set of dates from a specified start date (the last date in the current context) going back a given number of intervals (12 months). This allows the measure to dynamically calculate total sales for the trailing 12 months relative to any filter context, such as a specific year or month.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
PREVIOUSMONTH
Why it's wrong here
PREVIOUSMONTH returns a single-column table containing all dates from the immediately preceding calendar month, based on the first date visible in the current filter context. This function is hard-wired to a one-month lookback, so it cannot generate a rolling 12-month window of dates without being called repeatedly and concatenated via UNION or CALCULATE across multiple month values. Because it does not accept a period or interval argument and cannot produce a multi-month contiguous date range, it fails the requirement of a dynamic trailing 12-month measure.
- ✗
DATEADD
Why it's wrong here
DATEADD shifts a given set of dates forward or backward by a specified interval, such as months or years, while retaining the shape of the original range. To produce a rolling 12-month total, DATEADD alone is insufficient because it only relocates an existing date range; you would need to define a base period and then use CALCULATE to filter the model, and the shifted range still requires a reference range rather than returning the last 12 months directly from the current date. Thus it is not a standalone solution for a rolling 12-month period.
- ✓
DATESINPERIOD
Why this is correct
DATESINPERIOD returns a table of contiguous dates starting from a specified start date and extending for a given number of intervals (months, quarters, or years), either forward or backward. For a rolling 12-month calculation, you can use CALCULATE(SUM(Sales[Amount]), DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -12, MONTH)) to include exactly the trailing 12 months up to and including the current maximum date. This function is purpose-built for arbitrary date ranges anchored on a single date, making it the correct choice for this scenario.
- ✗
SAMEPERIODLASTYEAR
Why it's wrong here
SAMEPERIODLASTYEAR returns a table of dates shifted exactly one year earlier while preserving the length and boundaries of the currently active date range. For example, if the current selection is a single month, it returns that same month in the previous year; if the selection is a quarter, it returns the equivalent quarter a year prior. It does not aggregate multiple periods into a 12-month span, so it is unsuitable for a rolling 12-month total and is therefore incorrect.
About these practice questions
Courseiva writes every PL-300 question from scratch — 524 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This PL-300 practice question is part of Courseiva's free Microsoft certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PL-300 exam.