Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
HI there,
I have a measure to calculate the sales for a range of dates taken from a slicer:
Sales for Date Range = CALCULATE(SUM(Sales[NetTotal]), FILTER(Sales, AND(Sales[CheckDate].[Date] <= MAX('Calendar'[Date]), Sales[CheckDate].[Date] >= MIN('Calendar'[Date])) ))
What I am trying to figure out is how to create a measure for the same period LY. My work has the need to pull reports for all different kinds of date ranges and compare them to the same period last year, so my "Today", "MTD", "YTD", "LY MTD", "LY YTD" measures are not quite cutting it, and I'm having difficulty with phrasing the MIN/MAX dates to go back a year.
Any suggestions most appreciated!
Solved! Go to Solution.
Hi @golfgirl1111,
You can try to use below formula to achieve your requirement if it suitable for your requirement:
MTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[MonthNo]),VALUES('Calendar'[Date].[Year])) YTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[Year])) LY MTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESMTD(Calendar[Date]),-1,YEAR)) LY YTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESYTD(Calendar[Date]),-1,YEAR))
Regards,
Xiaoxin sheng
Hi @golfgirl1111,
You can try to use below formula to achieve your requirement if it suitable for your requirement:
MTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[MonthNo]),VALUES('Calendar'[Date].[Year])) YTD = CALCULATE(SUM('Fact'[Amount]),FILTER(ALLSELECTED('Fact'),[Date]<=MAX('Fact'[Date])),VALUES('Calendar'[Date].[Year])) LY MTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESMTD(Calendar[Date]),-1,YEAR)) LY YTD = CALCULATE(SUM('Fact'[Amount]), DATEADD(DATESYTD(Calendar[Date]),-1,YEAR))
Regards,
Xiaoxin sheng
Can you please some sample data and the output you expect. If you have the pbix and share it on one-drive with the link , it will help find the right solution.
Cheers
CheenuSing
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
95 | |
76 | |
65 | |
51 |
User | Count |
---|---|
146 | |
109 | |
106 | |
88 | |
61 |