Conditionals in workflows

Hi @raulpresa , and welcome to the KNIME community. As you have found the Rule Engine is limited to returning literals or single column/variable values but cannot handle any form of calculation or manipulation.

Conditional value calculations can be included in KNIME by using the Column Expressions node, which you may need to install.

There is also now a Variable Expressions node which is the same but for flow variables.

There are other way of doing conditions too. The Math Formula node has an if statement but is limited to working with numeric values only.

The String Manipulation node can also perform conditions but that functionality is rather hidden away. See Fun with String Manipulation's "undocumented features"

Beyond that Java Snippet is also an option but does require some Java knowledge and arguably a slightly higher learning curve.

For the type of expression you have as an example I would suggest Column Expressions, but if you have to execute it on large amounts of data, String Manipulation or Java Snippet will be much faster.

2 Likes