Forum Discussion

DemoFour's avatar
DemoFour
Icon for Continued Contributor rankContinued Contributor
4 years ago
Solved

How to show Previous month in date table

Hi folks, I have a date table and within this I have a column that shows the current month so I can then create a Flag for current month. Number.ToText(Date.Year(DateTimeZone.SwitchZone(DateTime...
  • Anonymous's avatar
    Anonymous
    4 years ago

    You can add a custom column like so:

     

    = Table.AddColumn(PriorStepOrTableName, "Month Flag", each if Date.IsInCurrentMonth([Date]) then "Current Month" else if Date.IsInPreviousMonth([Date]) then "Previous Month" else "All Other Months", type text)

     

    You can also use Date.IsInPreviousNMonths to take this as far back as you'd like.

     

    --Nate