In your transform steps, you can apply conditional logic to determine if transformational changes should occur. You can build logical tests into your transformations in multiple levels:
Through the Transform Builder, you can build conditional tests using if/then/else or case logic to manipulate on the data.
falseand specify values if
true(then) or if
true, a different value can be written.
After the transform is added to the recipe, actions can then be taken based on the values in this new column.
For more information, see Case Transform.
You can also apply conditional logical as part of your function definitions for other transforms.
For example, the following replaces values in the same column with
IN if they are greater than 0.5 or
set col: testCol value:IF($col >= 0.5, 'IN','OUT')
In the above, the token
$col is a reference back to the value defined for the column (
testCol in this case). However, you can replace it with a reference to any column in the dataset.
You can use the IF function in any transform that accepts functional inputs. For more information, see IF Function.
set col: testCol value:IF($col >= 0.5, 'IN',(IF($col >= 0.35, 'MAYBE IN','OUT')))
set col:testCol value:CASE([ $col >= 0.75, 'IN', $col >= 0.35, 'MAYBE IN', 'OUT'])
|If test||Test||Output if |
|If above is |
|If above is ||default|
For more information, see CASE Function.
Logical operators can be applied to your function expressions to expand the range of your logical tests.
In the above example, suppose you have a second column called,
Paid, which contains Boolean values. You could expand the previous statement to include a test to see if
set col:testCol value:CASE([ ($col >= 0.75 && Paid == true), 'IN', ($col >= 0.35 && Paid == true), 'MAYBE IN', 'OUT'])
The above performs a logical AND operation on the two expressions in each tested case. The logical operator is
You can also reference explicit functions to perform logical tests. The above might be replaced with the following:
set col:testCol value:CASE([ AND($col >= 0.75, Paid == true), 'IN', AND($col >= 0.35, Paid == true), 'MAYBE IN', 'OUT'])
|Logic||Logical Operator||Logical Function|
Depending on the structure of your transform and your preferences, either form may be used.