case when in knime

Hello I’m still learning this tool, so apologize if this is a pretty easy question.

So I want to use a node that would be similar to a case when statement. I have a condition to see if a specific column contains the string Partner and if it does I want it to use t1.acct_id and if doesn’t then I want it to use t2.acct_id. It seems like the rule engine would be the best choice, but I’m having trouble implementing it.

You can take a look at this example using rule engine and java.

Rule engine is pretty handy but you should read/learn about the syntax with the TRUE statement providing the default.

And if you absolutely must you can always have your own SQL database from within KNIME and use SQL syntax.

1 Like

Hi hookemhorns,

The rule engine cointains a “LIKE” function, which you could use in cases where you don’t know 100% what the row value looks like, but contains the word partner.
For example:

$string column name$ LIKE “*Partner *” => “t1.acct_id”
TRUE => t2.acct_id

The syntax of the rule engine is pretty nicely described in the example code, when adding a rule engine and opening it (in green font).

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.