Trouble executing a column loop


I have a data table that looks something like this:

Object Number; Image 1; Image 2; Image 3;
1; 0; 0; 0;
2; 1; 0; 1;
3; 1; 0; 0;
4; 1; 1; 0;

I want KNIME to count the occurrence of “1” and “0” for each image (column) and output it as a table.

The way I was trying to do this was to add a Column List Loop Start node and include the columns I wanted to do this for (Image 1, Image 2, and Image 3 while excluding Object Number). Then I added a Value Counter and finished with the Loop End (Column Append).

I can get the Value Counter to work for one column at a time, but my real data sets could have 30+ images to analyze. I can’t get the counter to work within any loop function. I keep getting error messages that certain columns don’t exist within the loop and therefore it cannot execute.

I have uploaded the excerpt from my pipeline going over this problem.

Thanks in advance for any guidance!

KNIME_CountTroubleshooting.knwf (12.5 KB)

Hi @nagemneuman

I would use a GroupBy node, but with NO group columns configured.

And if you want to use a loop :slight_smile: . Configure the ValueCounter with the flow variable created by the Column List loop start.
Schermafdruk van 2023-03-08 07-56-24

gr .Hans
(And yes I’ḿ aware that not everbody is in favor of using loops)


Thanks gr. Hans!

I tried using the GroupBy node with no group columns configured. The count aggregation method under the Manual Aggregation tab counts the total number of rows in the column rather than how many 1’s and how many 0’s there are within that column. Any suggestions on this?

I also tried assigning the flow variable in the Value Counter and that did work, so thank you!

1 Like

Hi @nagemneuman

Tnx for validating the solution. Did you use Sum as the Aggregation method, see KNIME_project3.knwf (20.0 KB) ?

gr. Hans

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