How to conditionally write information to a column

Options

if I have two columns both with a date but only in sometimes I want to one of the dates, how do I conditionally return that value to a new column?
Eg: if we have two columns (1 and 2), if a field in column 1 is blank then I want to display data from column 2 in a new column created in a step before. If column 1 is NOT blank, then I would want data from column 1 in the new column created.

Answers

  • Jeff_146001
    Jeff_146001 Posts: 296 admin
    edited September 2020
    Options

    @Bachir_121885 There are 2 routes to achieve this:

    No-Code

    1. Add the action, Tables: Start a workflow for each row.
    2. In the subprocess, add 2 different Tables: Update a row actions.
    3. For each of those Update actions, add a Condition to only run if the column (1 or 2) is not empty.

    Low-Code

    1. Add the action, Tables: Apply formulas to columns
    2. Add code somewhat like the code below. This assumes that your columns are named Column 1 and Column 2 and you have a column named Result where you store the correct date, so update as needed:
    if (columns['Column 1']) {
      columns['Result'] = columns['Column 1'];
    } else if (columns['Column 2']) {
      columns['Result'] = columns['Column 2'];
    }
    

    The code if (columns['Column 1']) evaluates to TRUE if Column 1 is not blank and not 0.