Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi,
I was using the below calculation to find the PY Sales Value,
Sales SPLY = Calculate([Sales],SAMEPERIODLASTYEAR('sales'[Sales Date]))
but get the error SAMEPERIODLASTYEAR expects a contiguous selection when the date column is not unique, has gaps or it contains time portions becuase I dont have sales continuously everyday.
I tried the Dateadd function, but still same issue arises.
Is there other ways to calculate the PY measure dynamically?
Thanks
Solved! Go to Solution.
Hey @dataandme ,
don't you have a calendar / date table? If not, you should build one, connect it with the fact table with 1:* realationship (from 'Calendar'[Date] to 'Sales'[Sales Date]), then use this calendar table in your calculate, instead of Calculate([Sales],SAMEPERIODLASTYEAR('sales'[Sales Date]))
it becomes Calculate([Sales],SAMEPERIODLASTYEAR('Calendar'[Date]))
😉
Please share sample data and desired out put.
Hey @dataandme ,
don't you have a calendar / date table? If not, you should build one, connect it with the fact table with 1:* realationship (from 'Calendar'[Date] to 'Sales'[Sales Date]), then use this calendar table in your calculate, instead of Calculate([Sales],SAMEPERIODLASTYEAR('sales'[Sales Date]))
it becomes Calculate([Sales],SAMEPERIODLASTYEAR('Calendar'[Date]))
😉
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.