Add conditional column

The Add conditional column allows you to create a new column based on If...Then...Else schema with possibilities to add nested conditions in order to create conditional logic for data manipulation.

The condition is expressed in the if parameter with a condition object, which is the same object expected by the condition parameter of the filter step). Conditions can be grouped and nested with logical operators and and or.

The then parameter only supports a string, that will be interpreted as a formula (cf. formula step). If you want it to be interpreted strictly as a string and not a formula, you must escape the string with quotes (e.g. ‘“this is a text”’).

if...then...else blocks can be nested as the else parameter supports either a string that will be interpreted as a formula (cf. formula step), or a nested if if...then...else object.

Step parameters

  1. New Column (string): Enter a name for the new column that will be created based on your conditions and formulas.

  2. If Condition: Define the condition(s) that will be evaluated.

  3. Then Formula: Specify the formula to be applied when the condition is true.

  4. Else Formula: Specify the formula to be applied when the condition is false.

Example

Input

Add - Add conditional column input

Configuration

{
    "new_column": "Category",
    "if": {
            "and": [
                {
                        "column": "Price",
                        "operator": "ge",
                        "value": 50
                },
                {
                        "column": "Stock",
                        "operator": "gt",
                        "value": 10
                },
            ]
        },
    "then" "Premium",
    "else": "Standard"    
}

Where gt: greater than and ge: greater than or equal to

Output

Add - Add a conditional column output

Defining Conditions

You can create three types of conditions:

  1. Simple Condition:

    • Column Name: Enter the name of the column you want to filter on.

    • Operator: Choose from operators like equals, not equals, greater than, less than, etc.

    • Value: Enter the value to compare against.

  2. AND Condition: Combine multiple conditions that must all be true.

  3. OR Condition: Combine multiple conditions where at least one must be true.

Operators

The following operators are available for conditions:

  • eq (equals)

  • ne (doesn't equal to)

  • gt (is greater than)

  • ge (is greater than or equal to)

  • lt (is less than)

  • le (is less than or equal to)

  • in (is one of)

  • nin (is not one of)

  • matches (matches pattern)

  • notmatches (doesn't match pattern)

  • isnull (is null)

  • notnull (is not null)

  • from (starting in/on)

  • until (ending in/on)

Formulas

For the "Then" and "Else" parts, you can enter formulas that will be applied based on the condition results. These can be simple values or complex expressions. See the formula step for more information.

Nested Conditions

You can create nested conditions by using another If...Then...Else structure in the "Else" part of your condition.

Last updated

Was this helpful?