Math in Knime

Hi there, I’m new to Knime and I would like some advice on moving some of my spreadsheet workflow to Knime.

In my one sheet I have a formula that subtracts the 11th cell in a column from the second and puts the result in its own column.

The formula is =(C11-C2)

Is there a way to do this for an entire column of data and put the results in another column without using Python or R? I’m trying to move as much of my Sheet workflow into Knime because right now my Knime data goes into Google Sheets and then gets read from Google Sheets again to be processed.

Hi @danielvorster

The answer to your question is yes.
But based on your input it is impossible (for me at least) to tell you how. So it would be helpful for me and other Forum visitors if you provide some sample data that show what your data looks like at the start and what you expect after C11-C2 is executed.

gr. Hans

4 Likes

Hi @HansS, thanks for the reply.

So what I would like is C11-C2 and then the formula repeated down the entire column and the results written in another column.

in the example column I have what I would like

Hello @danielvorster
You can use Column Expressions node with the following code:

column("C") - column("C",-9)

Being ‘-9’ the reference row distance value

You have to be aware on the Advanced settings’ tab to set Enable multi-row access with a larger window size than the reference row distance + activate Use ‘null’ option

BR

4 Likes

@gonhaddock Thank you for the reply

So I could say column(“C”) - column(“C”,11) if I want C11-C2, that distance between the first value and the 11th

Hi @danielvorster
Sorry I just tested with a sum and pasted my test straight forward. For sure I should work the same with other math operators.

column("C") - column("C",-9)

Should be the right test for you

BR

1 Like

No worries at all, you helped so much. I’m sure I can figure the rest out.

@danielvorster our editing crossed each other, sorry for that:

P.S. I edited the correct formula in the marked solution post, for the records.

1 Like

Thank you so much for your help. Really appreciate it

2 Likes

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