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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Pbenedetto
New Member

Same Store Month over Month and Year over Year with slicer

Hi, I am trying to create a dax formula that I can use to calculate same store sales that reacts to date slicers and compares sales to the same period last year. I am able to calculate it where month vs prior year same month works but when I change the slicer to include all months I run into an issue. The issue is the year pulls in cases where the store went live half way through the pervious year the calculation returns all of the current year's data even though the store went live midway through the prior year. I need a function to only include data in the periods it was live in both periods and work with the same period last year function. 

 

Any ideas? 

1 REPLY 1
amitchandak
Super User
Super User

@Pbenedetto , Not very clear.

Something like this

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

last year MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-12,MONTH)))

 

MTD adjusted = if(isblank([last year MTD Sales]), blank(), [MTD Sales])

or

MTD adjusted = sumx(values(Date[Month Year]), if(isblank([last year MTD Sales]), blank(), [MTD Sales]))

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

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

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.