The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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?
@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.
User | Count |
---|---|
12 | |
8 | |
6 | |
6 | |
6 |
User | Count |
---|---|
24 | |
14 | |
13 | |
9 | |
7 |