Forum Discussion
Previous Year Sales Calculation Issue
- Anonymous4 years ago
Hi jlandsm4785 ,
I created some data:
Here are the steps you can follow:
1. Create measure.
LY = CALCULATE( SUM('Table'[Amount]),FILTER(ALL('Table'), 'Table'[Date]>=DATE(YEAR(MAX('Table'[Date]))-1,1,1)&&'Table'[Date]<=DATE(YEAR(MAX('Table'[Date]))-1,MONTH(MAX('Table'[Date])),DAY(MAX('Table'[Date]))) ))CY = CALCULATE( SUM('Table'[Amount]),FILTER(ALL('Table'), 'Table'[Date]>=DATE(YEAR(MAX('Table'[Date])),1,1)&&'Table'[Date]<=MAX('Table'[Date])))2. Result:
If you need pbix, please click here.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Update:
After thinking about this more i believe that the error is caused from the column being based off of Week Ending dates, so looking a year back will not generate a sales value to appear because the date it is looking to match with is not exact. I tried using the DATEADD function to shift the previous year value forward + 1 day. Still having issues, but this feels closer to a solution.
DAX:
Any guidance forward is appreciated.
- Anonymous4 years agoNot applicable
jlandsm4785 accept the solution if it fulfills your need.