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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Shineccx007
Helper II
Helper II

How to dynamic aggregate sum sales and same period last year

Hi Teams,

 

I have created two calendar tables to aggregate the sales total.

 

Date period is to apply the date type slicer on the filter.

Shineccx007_0-1728219428605.png

Shineccx007_1-1728219484223.png

Value entries date is from Value entries table "posting date"

Shineccx007_2-1728219546657.png

The relationship between value entries calendar table and date period table is "one to many" linked by the date.

 

I am able to get what I want in the slicer for the date selected. But I am not able to get the calculate 1 year before the slicer selected. Same period last year is showing all the data in the past, which is not I want.

 

For example,if I select slicer YTD, SPLY sales should sum the sales between 01/01/2023~10/04/2023

If I select past 6 months, the SPLY sales should sum the sales 04/01/2023~9/30/2023

if I select past12 months,the SPLY sales should sum the sales between 10/1/2022~9/30/2023

 

Shineccx007_3-1728219655660.png

 

I have tried several ways below,none of them works:

1. To switch the date under SPLY to sameperiodlastyear(date period[date]) but show error on the DAX and no result is showing there.

2. To mitigate by the value entiees calenda date,but seems data is not showing what I want either.
3. Create one more column LastYearSamePeriod under date period table, DAX show error. 

 

Can anyone help?

 

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Add a column to your calendar table "IsPastPY"  that is calculated on each refresh (so ideally daily).  Add that column as another filter when you use SAMEPRIODLASTYEAR.

View solution in original post

2 REPLIES 2
lbendlin
Super User
Super User

Add a column to your calendar table "IsPastPY"  that is calculated on each refresh (so ideally daily).  Add that column as another filter when you use SAMEPRIODLASTYEAR.

Hi Ibendlin,

 

I added a column "last year same period "under the date period table and aggregate by this column. I got my answer.

 

Thank you.

 

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