Category: Transform / Basic
This action calculates a new, or replaces an existing, column by using one or several ordered IF…THEN…ELSE conditions. The conditions are checked one by one until a satisfying condition is found. When a satisfying condition is found, the result is calculated and all other conditions are ignored. When no satisfying condition is found, the default calculation is applied.
|Create new column||This option creates a new column with the results of the rule. Enter a name for the new column in the text box at the right.|
|Replace existing||With this option, select the column that will contain the results of the rule, overwriting the existing values.|
|if||An expression that evaluates to either TRUE or FALSE which determines whether the then statement will be processed (i.e., the then will run when the if expression is TRUE.|
|then||The value inserted into the column when the if condition is TRUE. This can be entered as an expression or static value. Options: this is an expression or this is a text or number.|
You can add more if/then conditions using the Add more rules option. An else will be inserted between if/then pairs, indicating that later conditions are only run if previous conditions evaluate to FALSE. The if/then rules are evaluated in the order entered until one evaluates to TRUE, and the rest are ignored.
|Make empty||If none of the if statements evaluate to TRUE, enter an "empty" value.|
|Default to||Options: it's an expression or it's a text or number. Enter either an expression to be evaluated, or a static value,
in cases where none of the if statements evaluate to TRUE.
|Keep original value||If none of the if statements evaluate to TRUE, retain the original value.|
The order of conditions is significant as conditions are checked starting from the first (top). Therefore, conditions that come first have priority over conditions that come later.
While the same result can be achieved using an expression with nested if functions, the use of Rule action is recommended for clarity, readability, and the ease of rearranging the order.
Objective: Add a column describing the average spending potential in each country as low or high, based on the disposable income. The spending potential is high if the disposable income is $40,000 or more.
Source table: Average income and deductions
|Country||Gross income||Disposable income||Compulsory deductions|
Create new column: Spending
Calculated as: if ([Disposable income] > 40000), then HIGH.
If none of the condition above is met: Default to LOW
|Country||Gross income||Disposable income||Compulsory deductions||Spending|
Fast ways to create the action: