Forum Discussion

ElliotP's avatar
ElliotP
Post Prodigy
9 years ago
Solved

Show Word if between Two Dates

Evening,   I'm trying to create a column for dates which will show different categorisations depending upon the date range. The date ranges aren't within my table and I'm trying to code them into t...
  • MFelix's avatar
    9 years ago

    Hi ElliotP,

     

    Add a custom column with the following code:

     

    = 
     if 
     [Date] >=  #date(2017, 1, 1)  and [Date]  <=   #date(2017, 7, 15) 
    then "Term Time"
    
    else "Normal"

     

    The M code is:

    = Table.AddColumn(#"Renamed Columns", "Custom.1", each if 
     [Date] >=  #date(2017, 1, 1) 
    and [Date]  <=   #date(2017, 7, 15) 
    then "Term Time"
    
    else "Normal")

    Regards,

    MFelix