Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

View all the Fabric Data Days sessions on demand. View schedule

Reply
Anonymous
Not applicable

same period last year using SAMEPERIODLASTYEAR return nothing

I have a date dimension table with a date key and a date field. the date key is joined to the date key in sales table

but the

Total Sales LY = CALCULATE(SUM('Sales'[Today sales]), SAMEPERIODLASTYEAR('Date'[Date]))

return nothing

 

but I have another similar model using joint with date field rather than the date, the functions works. I am not sure if the difference causes the issue? Any one got a clue?

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

OK. Looks like expert has confirmed my theory that we SHOULD not have surrogate key in the Date dimension for the function to work. 

 

https://www.sqlbi.com/articles/data-import-best-practices-in-power-bi/

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Set up another simple model to test this. I was able to replicate the issue. 

 

If the date dimension is joined to a fact table with a date column (EG 2 may 2016), the sameperiodlastyear function (and the dateadd etc) will work.

 

If the date dimension is joined to a fact table with a datekey column (EG 20160502), the sameperiodlastyear function (and the dateadd etc) will not work.

 

Can anyone confirm this is a known issue with Power BI or something missing in my setup?

 

At the end of the day, as a workaround, I can always add a date column in the fact table. But it just does not make sense as the date dimension should use date key for joining. 

Anonymous
Not applicable

OK. Looks like expert has confirmed my theory that we SHOULD not have surrogate key in the Date dimension for the function to work. 

 

https://www.sqlbi.com/articles/data-import-best-practices-in-power-bi/

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors