sum of two columns multiple times

Hi all,

I want to do sum of two columns multiple times and result should be in New Columns.
Ex.
Col1 Col2 ColA ColB
1 2 3 1
2 4 5 1

Expected Result:
Col1 Col2 ColA ColB ColX ColY
1 2 3 1 4 3
2 4 5 1 7 5

ColX and ColY should show sum of Col1+ColA and Col2+ColB
please help

Thanks,
Mrunal

Hi there @Mrunal_S,

welcome to KNIME Cmmunity!

Can you be a bit specific? For example do you always have fixed number of columns for input? Are column names always same or they change? If they change do they follow some pattern by which can be recognizable? Does order change or you always want to sum first and third, second and fourth and so on…

After more info I believe someone will help you with suggestions or workflow example :wink:

Br,
Ivan

1 Like

Hi @Mrunal_S,

probably math formula multicolumn node did what you want.

BR
Hermann

Hay Ivan,

number of columns right now fixed its 24 columns i.e. 12 in 1st table and 12 in 2nd one and i want result such as sum of 1st column of 1st table with 1st column of 2nd table and so on and result should display in new 12 columns…

thanks,
Mrunal

hay hermann,
I have tried math formula (Multi column) but not succeed can you solve this for me…

thanks:)

Hi @Mrunal_S,

I see. You can try following approach. Use Column Appender to have all 24 columns in same table. Then use Column Expressions node to create expressions for each two columns you want to sum. So first expression would be:
column(0) + column (12)

second one would be:
column(1) + column (13)

and so on…

Considering you have fixed number of columns this should work just fine. Otherwise some looping with column filtering logic should be introduced.

Also there is a ticket for matrix operations and will give +1 on it cause you could use it here :wink:

Hope this helps!

Br,
Ivan

1 Like

Thanks Ivan :slight_smile:

1 Like

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