It returns a table of dates shifted one year back from the dates in the current context. This helps compare data from the same period last year.
Click to reveal answer
beginner
Write a simple DAX measure using SAMEPERIODLASTYEAR to calculate last year's sales.
Last Year Sales = CALCULATE(SUM(Sales[Amount]), SAMEPERIODLASTYEAR(Calendar[Date]))
Click to reveal answer
intermediate
Why do you need a continuous date column when using SAMEPERIODLASTYEAR?
Because SAMEPERIODLASTYEAR works on a continuous date column to correctly shift dates by one year. Missing dates can cause wrong or empty results.
Click to reveal answer
beginner
Can SAMEPERIODLASTYEAR be used with non-date columns?
No. SAMEPERIODLASTYEAR only works with date columns because it shifts dates by one year to find the matching period.
Click to reveal answer
intermediate
What is the difference between SAMEPERIODLASTYEAR and PARALLELPERIOD?
SAMEPERIODLASTYEAR shifts the dates exactly one year back keeping the same period length, while PARALLELPERIOD can shift by months, quarters, or years and allows more flexible offsets.
Click to reveal answer
What does SAMEPERIODLASTYEAR return?
AA table of dates shifted one year back
BSum of sales from last year
CCurrent year dates
DA single date value
✗ Incorrect
SAMEPERIODLASTYEAR returns a table of dates shifted exactly one year back from the current context.
Which column type is required for SAMEPERIODLASTYEAR to work correctly?
AContinuous date column
BBoolean column
CNumeric column
DText column
✗ Incorrect
SAMEPERIODLASTYEAR needs a continuous date column to shift dates by one year properly.
Which DAX function can be combined with SAMEPERIODLASTYEAR to calculate last year's sales?
ASUMX
BFILTER
CCALCULATE
DVALUES
✗ Incorrect
CALCULATE changes the filter context and is used with SAMEPERIODLASTYEAR to calculate last year's sales.
Can SAMEPERIODLASTYEAR shift dates by months or quarters?
AYes, it can shift by months
BNo, only by one year
CYes, by quarters
DYes, by days
✗ Incorrect
SAMEPERIODLASTYEAR only shifts dates exactly one year back, not by months or quarters.
What happens if the date column has missing dates when using SAMEPERIODLASTYEAR?
AIt still works perfectly
BIt fills missing dates automatically
CIt returns an error
DIt may return incorrect or empty results
✗ Incorrect
Missing dates can cause SAMEPERIODLASTYEAR to return wrong or empty results because it expects continuous dates.
Explain how SAMEPERIODLASTYEAR helps in comparing sales data year over year.
Think about how you compare this year's sales to last year's same time.
You got /4 concepts.
Describe the correct way to write a DAX measure using SAMEPERIODLASTYEAR to calculate last year's total sales.
Combine CALCULATE and SAMEPERIODLASTYEAR with SUM.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the SAMEPERIODLASTYEAR function in Power BI?
easy
A. To calculate the total sales for the current year
B. To compare data from the same period in the previous year
C. To filter data for the current month only
D. To create a new date column with next year's dates
Solution
Step 1: Understand the function's purpose
SAMEPERIODLASTYEAR shifts the date context back exactly one year to compare the same time periods.
Step 2: Identify the correct use case
It is used to compare measures like sales or revenue from this year to the same period last year.
Final Answer:
To compare data from the same period in the previous year -> Option B
Quick Check:
SAMEPERIODLASTYEAR compares last year's period [OK]
Hint: Think "same time last year" for comparison [OK]
Common Mistakes:
Confusing it with total aggregation functions
Using it to filter current year data
Assuming it creates future dates
2. Which of the following is the correct syntax to use SAMEPERIODLASTYEAR with a date column named Sales[Date]?
easy
A. SAMEPERIODLASTYEAR('Sales'[Date])
B. SAMEPERIODLASTYEAR(Sales[Date])
C. SAMEPERIODLASTYEAR(Sales.Date)
D. SAMEPERIODLASTYEAR([SalesDate])
Solution
Step 1: Recognize correct table and column reference
In DAX, table and column names are referenced as 'TableName'[ColumnName], so 'Sales'[Date] is correct.
Step 2: Check syntax correctness
SAMEPERIODLASTYEAR(Sales[Date]) omits single quotes around the table name. SAMEPERIODLASTYEAR(Sales.Date) uses invalid dot notation. SAMEPERIODLASTYEAR([SalesDate]) uses an incorrect column name format.
Final Answer:
SAMEPERIODLASTYEAR('Sales'[Date]) -> Option A
Quick Check:
Correct DAX column reference uses quotes and brackets [OK]
Hint: Use single quotes for table, brackets for column [OK]
But it returns an error. What is the likely cause?
medium
A. Measure name cannot contain spaces
B. SUM function cannot be used inside CALCULATE
C. SAMEPERIODLASTYEAR requires a numeric column
D. Missing single quotes around the table name 'Sales'
Solution
Step 1: Check table and column references
The table name 'Sales' must be enclosed in single quotes when referenced in DAX, so Sales[Date] is invalid.
Step 2: Understand function requirements
SUM inside CALCULATE is valid, SAMEPERIODLASTYEAR requires a date column, and measure names can have spaces.
Final Answer:
Missing single quotes around the table name 'Sales' -> Option D
Quick Check:
Table names need single quotes in DAX [OK]
Hint: Always quote table names in DAX formulas [OK]
Common Mistakes:
Forgetting single quotes around table names
Thinking SUM can't be inside CALCULATE
Assuming SAMEPERIODLASTYEAR needs numeric columns
5. You want to create a measure that shows the percentage change in sales compared to the same period last year. Which DAX formula correctly uses SAMEPERIODLASTYEAR to calculate this?
hard
A. Sales YoY % = CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR('Sales'[Date])) - SUM('Sales'[Amount])
B. Sales YoY % = SUM('Sales'[Amount]) / SAMEPERIODLASTYEAR('Sales'[Date])
D. Sales YoY % = SUM('Sales'[Amount]) - CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR('Sales'[Date]))
Solution
Step 1: Understand the percentage change formula
Percentage change = (Current - Previous) / Previous, so we need current sales minus last year's sales divided by last year's sales.
Step 2: Analyze each option
Sales YoY % = DIVIDE(SUM('Sales'[Amount]) - CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR('Sales'[Date])), CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR('Sales'[Date]))) correctly uses DIVIDE to avoid errors and calculates the difference over last year's sales. Sales YoY % = SUM('Sales'[Amount]) / SAMEPERIODLASTYEAR('Sales'[Date]) divides sales by a date column, which is invalid. Sales YoY % = CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR('Sales'[Date])) - SUM('Sales'[Amount]) subtracts current from last year without division. Sales YoY % = SUM('Sales'[Amount]) - CALCULATE(SUM('Sales'[Amount]), SAMEPERIODLASTYEAR('Sales'[Date])) calculates difference but not percentage.