Dynamic Switching based on row data

Hello

I am fairly new to KNIME and just when I thought that I have the hang of it I am caught up in a seemingly simple problem which I can’t solve!
I am trying to implement a switch based on a data in my row.
For example if my table has “foo” in column FooBar then evaluate top output else evaluate bottom output.
I have seen that the “IF switch” node can be controlled over variables only. The same is true for “Java IF (Table)” node. This means that I need to create a flow variable based on the data. At this point I was expecting to find a Rule Engine vith a Variable output but it was not the case.

One solution which I can think of is to use the “Table Row to Variable” node to convert all columns (of which I only need one) to variables then a “Variable expression” node to evaluate the data in the FooBar column and to create a new variable to control the IF switch. This would most probably work but it just seems to be a really complicated solution to a simple problem.
(Also what would happen if I already have variables created using the “Table Row to Variable” node but this happened before the FooBar column was created. Will there be double variables or will KNIME recognise that these variables already exist?)
Can you provide an example or best practice?

Thank you!

If you have just 2 brunches you can use filtering approach. Use Row Filter or Rule engine node for “foo” and continue processing on brunches. If you need combined result use Concatenate node.

1 Like

Thank you for your response!
I solved the problem by using the “Nominal Value row splitter” node to split the table based then I was able to use concatenate to merge it again. This works for one row as well but will give a warning.
This solution worked just like how I pictured the IF and END IF could work.

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