Need help on loops and variables


I'm looking for some help on loops and variables. I've read the

, but it hardly says anything about that and the posts in the forum are difficult to understand because of my lack of previous knowledge on the topic, I'm also very new in Knime.

Are there any documents or simple (very simple) workflows in order to learn?

Thanks in advance.


I recommend you to buy and read the following books:

KNIME Beginner's Luck
The KNIME Cookbook

The latter has a chapter about loops and a chapter about flow variables. Both are well written and helped me learning KNIME. And no, I am not getting any money for my recommendations. ;-)


Well, I suppose I'm missing something, but I don't know what it is.

I'm trying to use a loop that is executing a certain number of times, but  I don't want it to be predefined manually, I want to use a flow variable instead. The number of times is different every execution.

I supposed I  had to use a Counting Loop Start, but I can't configure it in order to set the number of times.

At the moment, I'm using a  Generic Loop Start  and a Variable Condition Loop End in order to create an infinite loop and using a Breakpoint node which I think it's not an elegant solution.

How can I configure proprerly the Counting Loop Start? or is there any better solution?


The best way to do this:

1. use GroupBy Node and Count function - count number of rows

2.then TableRow to Variable node - create variable with row count

3. next pass variable from point 2 to Counting Loop Start Node (FlowVariable card --> select your variable name)

4. Next use RowFilter Node (Include rows by number and RowRangeStart=currentIteration and RowRangeEnd=currentIteration)

5 and that's all (Loop End at the end of course)

Please see attached a screenshot and a workflow illustrating how to use the Counting Loop Start node together with a flow variable.


Thanks, that  made it clear to me how to use the counting loop.

Just another question. How to use the IF Switch Node? My idea is to choose between two possible paths.

  • The first path is chosen if the input table is empty
  • The second path is chosen if the input table contains data



That's right, the IF Switch node lets you choose between two paths, which can be reunited with the End IF node. You can control it manually or by a flow variable, the latter must be a String type variable holding the value "both", "bottom" or "top".

Please see the screenshot attached!


Thank you, Marc