Rule Engine or Expression Node for updating a recordset

For a Table containing contact information
In SQL I could do something like one field is empty replace with another field : i…e If length(myField1)<1 then set myField1 = myField2

Doing this logic and updating records does not seem very intuitive and seems to take many steps.

Basic conditional logic using the fields to set and update values

Hi @arvindev,

in KNIME you have to do this in two steps.

  1. String Manipuation Node: length(myField1) append new column "Check myField1
  2. Rule Engine Node: $Check myField1$ < 1 => myField2.
    TRUE => myField1

You have to choose “Replace Column: myField1”

Regards,
Brotfahrer

The new Expression node (from version 5.3) can do it in one expression:

empty_to_missing handles both a MISSING cell in myField1 and an empty string.
If you want to have a longer “replacement chain” you need to nest the if statements.

The screenshot is from the upcoming version (5.4), which is why you can see “Add expression”, which could also be helpful to avoid multiple nodes replacing one column each.

1 Like

The Column Expressions node can handle this very easily.