Loop over unique rows in KNIME

I am very new to KNIME and I have a simple question.

How to iterate through rows with unique values and perform some formula on them? For example, i have a dataset:

Fruit~ Amount, Price
apple 2 1$
apple 3 1$
banana 1 1.5$
apple 1 1$
banana 3 1.5$
apple 1 1$
strawberry 5 3$
strawberry 4 3$
banana 2 1.5$

I would like to iterate through each row of the “Fruit” column and to calculate [Amount*Price] and save the result for three different fruit types in in three different tables.

How to tell KNIME that he needs to calculate [Amount*Price] only for bananas, or only for apples, or only for strawberries separately? Which iterator can i use here? I need to know how to do it with Loop iterator.

Im thinking something like: LOOP --> Math Formula --> save separate CSV.

Thank you in advance.

Hi there @Milovanova,

welcome to KNIME Community!

You are on the right path and loop node you are looking for is Group Loop Start.

To write separate CSV file in each loop iteration check this example workflow from KNIME Hub:

Happy KNIMEing!



Hello Ivan,

a little recap on my problem, what if i do not want to save each time the result in a separate table, but instead i want to create ONE table (called [Result]) and constantly update it?

For example, 1) I calculate [AmountPrice] for babanas and put the results into a ‘Result’ table, --> then, 2) I do the same for apples, [AmountPrice], and would like to UPDATE the ‘Result’ table, meaning I want to add the rows of the apple multiplication results just right after banans multiplication results.
So that my table would look like:
1.5$ ((bananas)
4.5$ (bananas)
2$ (start adding apples results)
… etc

P.S: in the ‘Results’ table i don’t need what I wrote in the brackets, I just need the multiplication result.

Thank you in advance,

Hi @Milovanova,

well you can either close loop with Loop End node which will concatenate all the results and then use CSV Writer to write all results at once. Or you can use CSV Writer in a loop with append option checked. Both should work just fine :wink:


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