Calculate Mean for different number of columns in a loop


I am really new in Knime and I want to calculate the mean between some columns.

I have a loop on the Excel sheets and in every EXCEL sheet I have a different number of columns:
Sheet1 have 2 columns
Sheet2 have 4 columns
Sheet3 have 7 columns

I need to read the sheet in the loop and than calculate on the columns in the sheet the mean (for every row):
First loop I have
Sheet1 have 2 columns → calculate the mean on 2 columns

The second loop I have:
Sheet2 have 4 columns -->calculate the mean on 4 columns

and so on…

How can I calculate the mean without automatically?

thank you very much for any help!

Have a nice evening for everyone,


Hi Petra,

you want to calculate the mean of each column, not the entire table? This can be done with the GroupBy Node. You probably figured that much.
It has 3 ways of selecting columns for aggregations: Manually/statically setting them, using pattern matching on the column name, or selecting them by data type. Using the latter option should give you the desired results.
I also opted to keep the column names, should make handling the results downstream a little easier.

calc mean for dynamic number of cols.knwf (12.3 KB)

The mean for every row can be calculated with the column aggregator node. If you enforce exclusion it does not matter that the excel sheets have various amounts of columns.
hope that helps
best regards

1 Like

Aw, I can’t read. Thank you for pointing that out. :slight_smile:

The solution is described unambiguously, here’s the adapted WF anyway:
calc mean for dynamic number of cols.knwf (16.8 KB)

1 Like

I knew it it was a real not complicated thing!!!
Woow thanks to both of you @Thyme and also to @Daniel_Weikert .
Really helpful! sometimes I think in much more complicated way of doing things :slight_smile:


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