Calculate mean ignoring zeros

Hi everybody.

I am new in Knime and I have a big table that I want to calculate the Mean of the rows. But I want to ignore the zeros. So, if the row has two 5 and eight 0, the mean should be 5 instead of 1 (10 (5+5)/10 (2+8)).

The sheet has the data I want to calculate.

Can I get some help about it? Thanks.

Ratings4mean.xlsx (88.5 KB)

You could convert the 0 to missing values for example with the Math Formula (Multi-column node):

if($$CURRENT_COLUMN$$ == 0, "NaN", $$CURRENT_COLUMN$$)

And then if you use groupby for mean values it should ignore all missing cells.

3 Likes

I think that your idea works only if I want to calculate mean of the rows. I want to calculate the mean of the values in all columns in the same row.

@beginner’s method still works, except that you have to use the Column Aggregator to calculate the means instead of GroupBy.

4 Likes

Ok. Yes, it works with the Column Aggregator.

Thanks for everybody!

1 Like

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