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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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

Power BI Monthly Update - August 2025

Check out the August 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.