Search code examples
powerbidaxm

What is the opposite of EOMONTH() in Power BI (DAX)


What is the opposite of EOMONTH()? I am trying to find the beginning date of 12 months ago. Would it be EOMONTH(Current Date,12)-1?

Any direction would be great. TIA


Solution

  • In general, the opposit function is STARTOFMONTH:

    =STARTOFMONTH('Date'[Current Date])  
    

    If you want to get the first day of the month 12 months ago:

    = STARTOFMONTH ( DATEADD ( 'Date'[Current Date], -12, MONTH ) )
    

    This measure will return the first date of the same month a year ago (i.e., for 2018-09-22, it will return 2017-09-01). Current month is included, so you will get a total of 13 months. If you need only 12 months total:

     = STARTOFMONTH ( DATEADD ( 'Date'[Current Date], -11, MONTH ) )
    

    If you are trying to compute something over a rolling 12 months period, this article should help: 12-month Rolling Average in DAX