Forum Discussion

vpatel55's avatar
vpatel55
Kudo Commander
4 years ago
Solved

Shifting dates one year back

I am trying to shift a column of dates by one year.  I have tried SAMEPERIODLASTYEAR, PARALLELLPERIOD and DATEADD. I want to avoid simply subtracting 365 days.   They all return the error "The True...
  • vpatel55's avatar
    vpatel55
    4 years ago

    amitchandak pointed me in the right direction such that I could use the inbuilt time shifting functions but ignoring the current day. I'm including this post too if anyone finds it useful, as I wanted MTD last year, but ingoring the current day. Here is the code for that:

     

     

    MTD previous year = 
    VAR _max =
        TODAY () - 1
    VAR _min =
        EOMONTH ( _max, -1 ) + 1
    RETURN
        CALCULATE (
            [Expression)],
            DATEADD ( DATESBETWEEN ( dimCalendar[Date], _min, _max ), -1, YEAR )
        )