Forum Discussion

gonrodrigues's avatar
gonrodrigues
Helper III
10 years ago
Solved

Custom Column Homologous Month

Hello,

 

To create colum Current Month I used this:

 

Table.AddColumn(MonthName, "CurrentMonth", each Date.IsInCurrentMonth( [Date] ))

and if I want to creat two more: "HomologousMonth" and "PreviousMonth"? I have this custom columns:

 

 

I'm not familiar with DAX :/

 

Thanks!

 

  • Eric_Zhang's avatar
    Eric_Zhang
    10 years ago

    gonrodrigues

     

    You can get the HomologousMonth with Date.IsInCurrentMonth as wellJust add one year to [Date] and predicate it with IsInCurrentMonth.

    Table.AddColumn(PreviousMonth, "HomologousMonth", each Date.IsInCurrentMonth( Date.AddYears([Date],1) ))



    If you have any question, feel free to let me know.

9 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Can you explain what you want PreviousMonth to be? Do you want the actual previous month or do you want it to be a TRUE/FALSE value like CurrentMonth. And I have no idea what you are going for with HomologousMonth, is that the same as the current month in a different year? And is that also TRUE/FALSE or something else?

    • gonrodrigues's avatar
      gonrodrigues
      Helper III

       

       Ok, there's a previous month Function and for homologous month? 

      • Eric_Zhang's avatar
        Eric_Zhang
        Microsoft Employee

        gonrodrigues

        Your requirement is not quite clear for me, please check if below DAX expressions work.

        CurrentMonth = YEAR([date])=YEAR(TODAY()) && MONTH([date])=MONTH(TODAY())
        
        previousMonth = YEAR([date])=YEAR(TODAY())&&MONTH([date])+1=MONTH(TODAY())
        
        HomologousMonth = YEAR([date])+1=YEAR(TODAY())&&MONTH([date])=MONTH(TODAY())


         

        If you have any question, feel free to let me know.