Build your first loop
In this tutorial you will build a loop that splits a table into chunks of three rows, counts the rows in each chunk, and collects the counts into a final summary table.
By the end you will have a working loop, understand how Loop Start and Loop End nodes are connected, and be able to see how data changes across iterations.
What you need
- Knime open with a new, empty workflow
- No extensions required — all nodes used here ship with the base installation
Step 1 — Create a test table
Add a Table Creator node to the canvas and open its configuration dialog.
Create a table with one column called letter and ten rows, each containing the letter A. This gives you predictable data to loop over.
Execute the node. In the output view, confirm you have a table with 10 rows and 1 column.
Step 2 — Add a Chunk Loop Start node
Find Chunk Loop Start in the node repository under Workflow Control → Loop Support and add it to the canvas.
Connect the output of Table Creator to the input of Chunk Loop Start.
Open the Chunk Loop Start configuration dialog and set:
- Rows per chunk to 3
This splits the 10-row table into chunks: 3, 3, 3, and 1 row.
Step 3 — Count rows in each chunk
Add a Value Counter node and connect the output of Chunk Loop Start to it.
Open its configuration and select the letter column. This counts how many times each distinct value appears in the current chunk.
Step 4 — Add a Loop End node
Add a Loop End node and connect the output of Value Counter to it. Open its configuration dialog and check these settings:
- Add iteration column: enabled
- Row ID policy: make RowIDs unique by appending a suffix
Execute the Loop End node by right-clicking it and choosing Execute.
Watch the Loop End node: it shows a loop icon while iterating and turns green when done.
Step 5 — Inspect the result
Open the output of the Loop End node. You should see one row per iteration — the Value Counter ran once for each of the four chunks.
The suffixes #0 to #3 in the RowID come from the Loop End node, which keeps RowIDs unique across iterations. The last row has a count of 1 because 10 rows don’t divide evenly into chunks of 3.
| # | RowID | count | Iteration |
|---|---|---|---|
| 1 | A#0 | 3 | 0 |
| 2 | A#1 | 3 | 1 |
| 3 | A#2 | 3 | 2 |
| 4 | A#3 | 1 | 3 |
Try changing the chunk size in Chunk Loop Start to 5 and re-executing. The number of iterations changes, but the loop body and end node stay the same. You should now get two iterations, each with a count of 5.
What you built
- A Chunk Loop Start that divides the table into pieces
- A Value Counter in the loop body that processes each piece
- A Loop End that assembles the results
- How loops work → — the concepts behind what you just built
- Iterate over a table row by row → — a more advanced loop pattern using flow variables
- Loop node reference → — all available loop nodes