Knime Calculation. How can I use a value from the row before for a calculation.

Hello,

enclosed there are two pictures with an excel formula. I have a fixed value at the beginning and I want to use this value in the next row for a minus and plus calculation with fixed values of the current row.

How can I use a value from the row before?
Thank you.


Hi @Frank2323 and welcome to the KNIME forum,

Since you are saying that you have a fixed value “at the beginning” which means you have a value for the first row and missing for the rest of the rows in the initial dataset, using Lag Column node solely won’t solve your issue.

I think you need a recursive loop in which you filter the top 2 rows, calculate the base for the second row, pass the first row to the final output and concatenate the second row to the rest of table and pass it to the loop start.

calculate_next.knwf (33.7 KB)

The Lag Column node can be used instead of making use of flow variables, but then you need more nodes to filter the additional columns.

:blush:

1 Like

Another option might be to use https://hub.knime.com/knime/extensions/org.knime.features.base/latest/org.knime.time.node.window.LoopStartWindowNodeFactory

2 Likes

Hi,

I just added a workflow to my KNIME Hub area which does exactly this. I did use the cumulative computation option of the Moving Aggregation node to solve it.

You can find the workflow here

https://hub.knime.com/iris/space/2019_07_15_Forum_calculate_next

Cheers, Iris

3 Likes

Thanks a lot

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