Looping over all columns and add/substract between the current column, and the second column

Dear Knime community,

I have an excel sheet with 100+ columns, named A,B,C etc.

I am trying to create a new excel file that would have the result of A-B, B-C, C-D, …

image

and therefore obtain this:
image

With three columns, it can be done manually. But I have more than a 100 of them, so it’s really not the best method. In the math loop, I can select the $$Current_Column$$, but cannot force the iteration to also selec the $$Current_Column$$ + 1 iteration.

The idea would be to write the following, in the yellow circle, but this returns an error.

Hope my issue is clear enough

Regards

hi Vincent,

Have a look at this workflow. This may not be the most elegant solution, but was the first solution I could think of. :crazy_face:

subtract-between-the-current-column-and-the-second-column.knwf (34.1 KB)

Here’s another solution. I fixed it a little.
Add_Substract Columns.knwf (16.6 KB)

The Idea is to transpose the table to use Aggregation node with Sum function.
Before node I assigned negative values to every other column.

Maybe using Java snippets is “cheating”, but the resulting workflow looks a bit simpler from the outside: Subtract_columns.knwf (11.6 KB)