Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
After creating a dimdate table I tried to calculate a measure by using SAMEPERIODLASTYEAR but it does not work.
Solved! Go to Solution.
Hello @peluca,
What is the structure of your data table? Also, I am hoping you have created the relationship between the date of your fact table and the calendar table.
I have recreated the scenario with a sample data:
And created a calendar table:
Calendar =
ADDCOLUMNS (
CALENDAR ( MIN ( dtTable[Order Date] ), MAX ( dtTable[Order Date] ) ),
"Year", YEAR ( [Date] ),
"Month", DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 1 )
)
And mark it as a date table.
Created the relationship:
Created measures:
Total Orders = SUM(dtTable[Order Quantity])
PY Orders =
CALCULATE ( [Total Orders], SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) )
Getting the results in visual:
Regards,
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Hello @peluca,
What is the structure of your data table? Also, I am hoping you have created the relationship between the date of your fact table and the calendar table.
I have recreated the scenario with a sample data:
And created a calendar table:
Calendar =
ADDCOLUMNS (
CALENDAR ( MIN ( dtTable[Order Date] ), MAX ( dtTable[Order Date] ) ),
"Year", YEAR ( [Date] ),
"Month", DATE ( YEAR ( [Date] ), MONTH ( [Date] ), 1 )
)
And mark it as a date table.
Created the relationship:
Created measures:
Total Orders = SUM(dtTable[Order Quantity])
PY Orders =
CALCULATE ( [Total Orders], SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) )
Getting the results in visual:
Regards,
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Thanks so much for your help!!
I had an issue regarding the format of my dimdate table
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
10 | |
6 | |
6 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
10 | |
6 |