If rule

Hi,

I need to solve some issue that I stuck on. I want to add some rule that will check if specify column exists and if so add that one to another and give result in new named column. If the column doesn’t exist, create new named column anyway but give values from the second column.

image

So this is something to explain the issue. I need to check if column B exists and if so add A to B and give result in new named column “A+B”.

image

Desired result. I tried use Math formula as it has great option to name colum, but the problem is that when the colum B does not exist it gives error.

So in other words column A always exist but B does not.
I know that it can be done easly but I don’t know how. Maybe in simple java but I can’t write codes.

Thank guys for your help in advance.

An If switch could look something like this. Using one of @Iris old entries.

kn_example_if_switch.knwf (76.4 KB)

2 Likes

You can use a Java Snippet node to check if the column exists, and put the value in a flow variable:

Then use a Vernalis IF Switch (Flow Variable Value) node (see https://nodepit.com/node/com.vernalis.knime.flowcontrol.nodes.bdt.varvalifswitch.FvvalIfSwitchNodeFactory2) to switch the branch:

image image

Steve

3 Likes