Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to create a column for a customize month

Hi, how to create a Month column if the date is N-10 days prior current month and N-10 days prior next month.

For example: 

Month

Start Date

(N-10 days prior current month)

End Date

(N-10 days prior next month)

July21st June21st July
August22nd July21st August
September22nd August20th September

 

 

  • Please try this column expression instead.

     

    MonthColumn =
    VAR thisdate = 'Date'[Date]
    VAR daysfromend =
        INT ( EOMONTH ( thisdate0 ) - thisdate )
    VAR monthtoformat =
        IF ( daysfromend <= 10EOMONTH ( thisdate1 )thisdate )
    RETURN
        FORMAT ( monthtoformat"yyyy-mm" )

     

    Pat

6 Replies

  • Anonymous , If you have date

     

    Then

    Start Date  = eomonth([Date],0) -10

    End Date  = eomonth([Date],1) -10

     

    If you have month name create a date fist like

     

    Date = "01-" & [Month] & "-" & [Year] // you can change data type to date

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak , based on the start and end date, how to create the month column?

      I have date field in my table.

       

      Month

      Start Date

      (N-10 days prior current month)

      End Date

      (N-10 days prior next month)

      2021-0721-6-202121-7-2021
      2021-0822-7-202121-8- 2021
      2021-0922-8-202120-9-2021
      • mahoneypat's avatar
        mahoneypat
        Icon for Microsoft Employee rankMicrosoft Employee

        You can create a DAX column with an expression like this.  Replace Table with your actual table name.

         

        MonthColumn = FORMAT(Table[End Date], "yyyy-mm")
         
        Pat