Forum Discussion

Tihannah's avatar
Tihannah
Icon for Resolver II rankResolver II
4 years ago
Solved

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 -

Enrollments_PY = CALCULATE(SUM('Enrollments'[enrollments]),SAMEPERIODLASTYEAR(DATEADD('Calendar'[Cal_Dt],+1,DAY)))
 
  • Hi,

    Simplify your existing measure to

    Enrollments_PY_tempCALCULATE(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

  • Hi,

    Simplify your existing measure to

    Enrollments_PY_tempCALCULATE(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's avatar
      Tihannah
      Icon for Resolver II rankResolver II

      This is SO close, but it's giving me PY Date to Date instead of Day to Day?

    • Tihannah's avatar
      Tihannah
      Icon for Resolver II rankResolver 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!!