Forum Discussion

CliffordAP's avatar
CliffordAP
Icon for Helper II rankHelper II
5 years ago

Calculate same day previous month DAX

Hello everyone!

     I think my inquiry should be an easy one.

I want to find a way to compute a date based on the output of another date.

Say I have the following date,

     DATE(2021,01,16)
I want to simply adjust this date to the same day of the previous month such that it has the following output;

     DATE(2020,12,16)

Apparently PREVIOUSMONTH(DATE(2021,01,16)) does not work.

Any ideas?

4 Replies

  • NVM!
    I figured it out. There is a simple way to do this.

     

    You can use the MONTH function to calculate the previous month of the output date, and subtract the number of months.

     

    DATE(2021,MONTH(DATE(2021,01,16))-1,16)

    output

    DATE(2020,12,16). 🙂

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hello CliffordAP 
    You can use dateadd .
    LastMonth = DATEADD('Table'[Date], -1, Month)