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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
dataandme
Frequent Visitor

Sales PY for Non Contiguous date range

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

1 ACCEPTED SOLUTION
Gabry
Super User
Super User

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]))

 

😉

View solution in original post

2 REPLIES 2
Rupak_bi
Super User
Super User

Please share sample data and desired out put. 



Regards
Rupak
FOLLOW ME : https://www.linkedin.com/in/rupaksar/
Gabry
Super User
Super User

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]))

 

😉

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.