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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Same period last year not working while filter both ways

Hello,

 

Currently I have a fact table that consists of Sales Date, Delivery Date and Sales $

Sales DateDelivery DateSales $

 

I have 2 filter tables that has calendar to filter Sales Date and Delivery Date:

Sales Date
Delivery Date

 

I used relationship filtering both way between 3 tables, because I want Sales Date to also filter Delivery Date

 

I want to then have Same Period Last Year based on Sales Date:

Sales $ LY = CALCULATE(SUM('Fact table'[Sales $]), SAMEPERIODLASTYEAR('Sales calendar'[Sales Date]))

 However it has thrown error: Function 'SAMEPERIODLASTYEAR' expects a contiguous selection.

 

I tried to bypass by putting:

Sales $ LY = IF(SELECTEDVALUE('Sales calendar'[Sales Date]) = BLANK(), BLANK(),
CALCULATE(SUM('Fact table'[Sales $]), SAMEPERIODLASTYEAR('Sales calendar'[Sales Date])))

It didn't work.

 

Is there any idea how I can overcome this?

 

Thank you beforehands!

 

BR,

Otter

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , You need to have a date table join both dates with the date of the date table(I think sales calendar). One join will be inactive. Make sure it marked as date table.

 

Assume delivery join is inactive

 

Then LY can be

Sales $ LY = CALCULATE(SUM('Fact table'[Sales $]), SAMEPERIODLASTYEAR('Date'[Date]))

 

 

Sales $ LY delivery = CALCULATE(CALCULATE(SUM('Fact table'[Sales $]),userelationship('Date'[Date], 'Fact table'[delivery Date] )), SAMEPERIODLASTYEAR('Date'[Date]))

 

 

Other options are

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),SAMEPERIODLASTYEAR('Date'[Date]))

 

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5bd4
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hello,

 

My relationships are like this:

Fact table <> Sales calendar (two way relationship)

Fact table <> Delivery calendar (two way relationship)

 

None of the relationships are inactive.

 

I want that I can use Date filters for either Sales Date and Delivery Date as separate Filters. I.e. when I choose a Sales Date, it will show different Delivery Dates in the other filter and vice versa.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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