A data analyst needs to create a measure in Power BI to analyze sales performance. The data model contains a 'Sales' table with a [SalesAmount] column and a 'Date' table that is marked as a date table. The measure must calculate the total sales for the equivalent period in the prior year. For example, if a visual is filtered to March 2025, the measure should return the sales total for March 2024. Which DAX formula should the analyst use?
The correct formula is CALCULATE(SUM('Sales'[SalesAmount]), SAMEPERIODLASTYEAR('Date'[Date])). Here's a breakdown of why:
The SAMEPERIODLASTYEAR function returns a table of dates shifted one year back from the dates in the current filter context. When a visual is filtered to March 2025, this function returns all dates for March 2024.
The CALCULATE function then evaluates the SUM('Sales'[SalesAmount]) expression using this new table of dates as its filter context, correctly calculating the sales for the same period in the previous year.
Incorrect Answer Explanations:
CALCULATE(SUM('Sales'[SalesAmount]), PREVIOUSYEAR('Date'[Date])) is incorrect because the PREVIOUSYEAR function returns all the dates from the entire previous year, ignoring the specific period (like a month or quarter) in the current filter context. This would return the total sales for all of 2024, not just March 2024.
SUM('Sales'[SalesAmount]) - CALCULATE(SUM('Sales'[SalesAmount]), SAMEPERIODLASTYEAR('Date'[Date])) is incorrect because it calculates the year-over-year change or variance in sales, not the sales total from the prior year period itself.
TOTALYTD(SUM('Sales'[SalesAmount]), 'Date'[Date]) is incorrect because TOTALYTD calculates the cumulative sum from the beginning of the year to the current date (Year-To-Date), which is a different calculation than comparing to the same period in the previous year.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does SAMEPERIODLASTYEAR do?
Open an interactive chat with Bash
Why is PREVIOUSYEAR different from SAMEPERIODLASTYEAR?
Open an interactive chat with Bash
When should you use TOTALYTD instead of SAMEPERIODLASTYEAR?
Open an interactive chat with Bash
Microsoft Power BI Data Analyst
Model the Data
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .