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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Shineccx007
Helper I
Helper I

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors