Forum Discussion
SAME DAY LAST YEAR
I used the following DAX to get same day last year. While it's giving me the correct amounts, it's not summing the amounts correctly. Either in a table or with a variance DAX. I am using a calendar slicer. Can anyone tell me what is happening here or how I fix it?
This is the DAX -
Hi,
Simplify your existing measure to
Enrollments_PY_temp = CALCULATE(SUM('Enrollments'[enrollments]),SAMEPERIODLASTYEAR('Calendar'[Cal_Dt]))
Now drag this measure
Enrollments_PY_final = SUMX(VALUES('Calendar'[Cal_Dt]),[Enrollments_PY_temp])
Hope this helps.
5 Replies
- VahidDM
Super User
- Ashish_Mathur
Super User
Hi,
Simplify your existing measure to
Enrollments_PY_temp = CALCULATE(SUM('Enrollments'[enrollments]),SAMEPERIODLASTYEAR('Calendar'[Cal_Dt]))
Now drag this measure
Enrollments_PY_final = SUMX(VALUES('Calendar'[Cal_Dt]),[Enrollments_PY_temp])
Hope this helps.
- Tihannah
Resolver II
This is SO close, but it's giving me PY Date to Date instead of Day to Day?
- Tihannah
Resolver II
Actually, that worked!! I just had to change it to -
Enrollments_PY_temp = CALCULATE(SUM('Enrollments'[enrollments]),SAMEPERIODLASTYEAR(DATEADD('Calendar'[Cal_Dt],+1,DAY)))Thank you!!- Ashish_Mathur
Super User
You are welcome.