Forum Discussion

Ocasio27's avatar
Ocasio27
Iron Contributor
Jul 06, 2020
Solved

Power Query 5 days ago rule

In the conditional column, I want to create a rule that, if a column value is less than 5 days ago, then the value should be "pending"

  • Ocasio27 

    Conditional column is only subset of custom columns with user interface to generate if ... then ... else

    Anyway, you already have some statement with fixed date. Stay on step where this formula was generated (or use Advanced editor) and change concrete date which is in form #date(2020,7,2) or so, on

    Date.From(Date.AddDays(DateTime.LocalNow(),-5))

     

13 Replies

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    Ocasio27 

    Insert first in the wizard any date you wish. In formula bar it will be something like

    = Table.AddColumn(#"Changed Type", "Custom", each if [A] > #date(2020, 7, 2) then "pending" else null)

    and be sure formula works with your data. After in formula bar change #date(...) on Date.From(Date.AddDays(DateTime.LocalNow(),-5))

    = Table.AddColumn(#"Changed Type", "Custom", each if [A] > Date.From(Date.AddDays(DateTime.LocalNow(),-5)) then "pending" else null)

     

    • Ocasio27's avatar
      Ocasio27
      Iron Contributor

      SergeiBaklan 

       

      It works but I explained it incorrectly and is not what I was expecting.

       

      I already have a conditional column with rules, if else if else, I can choose a column with dates and add after a specific date, but I can only input a fixed date, for example june 2 which is 5 days ago, however that query will change often and I need it to apply this rule for the last 5 days no matter when do I update it.

       

      Maybe the only way to make this work is with a custom column rather than a conditional column, but the conditional column is just easier to work with.

      • SergeiBaklan's avatar
        SergeiBaklan
        Diamond Contributor

        Ocasio27 

        Conditional column is only subset of custom columns with user interface to generate if ... then ... else

        Anyway, you already have some statement with fixed date. Stay on step where this formula was generated (or use Advanced editor) and change concrete date which is in form #date(2020,7,2) or so, on

        Date.From(Date.AddDays(DateTime.LocalNow(),-5))

         

Resources