Forum Discussion

SJHALANI's avatar
SJHALANI
Helper I
3 years ago
Solved

Create new column based on date

Hello, I have a column which has 'Contract End date' listed in it. I want to create a column 'Contract Status' next to it which does the following:   - if 'Contract End date' > current date, 'Co...
  • Einomi's avatar
    3 years ago

    Hi,

    You can try this

     

    Table.AddColumn(PrevStep, "ContractStatus", each if [Contract End Date] > Date.From(DateTime.LocalNow()) then "Active"
    else if [Contract End Date] > (Date.AddDays(Date.From(DateTime.LocalNow()),-60)) and [Contract End Date] < Date.From(DateTime.LocalNow()) then "Pending"
    
    else if [Contract End Date] < (Date.AddDays(Date.From(DateTime.LocalNow()),-60))  then "Inactive"
    else null)

     

    I have tried on my data and it worked.

     

    Hope it will be helpful