Forum Discussion

JustinDoh1's avatar
JustinDoh1
Icon for Post Prodigy rankPost Prodigy
4 years ago
Solved

How to express Next Month First Day, Prev. Month First Day etc. (Time intelligence question)

Hi Community,

 

I am trying to write DAX on following examples (as shown below):

 

Based on value of "Date" (like 02/20/2021, 01/10/2021), I would like to create column value like "Next Month First Day", "Current Month First Day", "2 Month..", "4 Month.." etc.

I think creating Column is what I needed now, but if there is a way to create Measure, I will use later.

 

Thanks.

 

 

 

 

 

  • Hi:

    If your matrix has month as column, then this would work as a measure:

    Next Month First Day =
    VAR dayone = CALCULATE(Max(Dates[Date]))
    return
    CALCULATE(dayone, DATEADD(Dates[Date],1,MONTH))+1

     

5 Replies

  • Hi:

    If your matrix has month as column, then this would work as a measure:

    Next Month First Day =
    VAR dayone = CALCULATE(Max(Dates[Date]))
    return
    CALCULATE(dayone, DATEADD(Dates[Date],1,MONTH))+1

     

      • Whitewater100's avatar
        Whitewater100
        Icon for Solution Sage rankSolution Sage

        Hi:

        NP. 

        Begin Next Month =
        VAR currdate = Dates[Date]
        return
        EOMONTH(currdate,0)+1
         
        If it works well, please accept as solution. Thanks!
  • Hi Justin:

    Anoter variation you might like is:

    =NEXTDAY(LASTDATE(Dates[Date]))

    It's less code and works if you are set up by month. Just FYI. Bill