Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Create a custom column that tracks if date is less than current day

Hi there, I currently have a date column called "closing date", and I want to create a new custom column in Power Query that will either give "Expired" or "Active" depending if the "closing date" ...
  • jbwtp's avatar
    jbwtp
    3 years ago

    Hi Anonymous,

     

    this is just an example to give you a taste of the possible solution. For your code you need to adopt the  Added Custom step. In your case if would look something like:

    #"Added Custom" = Table.AddColumn(#"Changed Type", "Status", each if [closing date] < Date.From(DateTime.FixedLocalNow()) then "Expired" else "Active", type text)

     

    If you are using a standard Add Column button in the main menu, this is the code that you need to paste into the dialog box:

     

    if [closing date] < Date.From(DateTime.FixedLocalNow()) then "Expired" else "Active"

     

    Cheers,

    John