Use Moving Aggregation node first for Quantity used column based on a quantity column (preliminary calc).
Lag Column node to Data and use
Math Formula Multi columns to calculate Quantity Used (add lagged column) and Calculate quantity using Data column and Quantity used.

Hi @newuser01,
its hard to read your question.
Please can you explain it with an example shown as a table or if you have the calculation available in a Excel spreadsheet you can also upload this example file.
Thanks

Here’s an example:
The data column is changed manually so that the extra is equal to 0.
But I want to automate this process using Knime.
And at the same time, the other calculations are happening

Hi @newuser01,
adding an additional column is not the problem. But i don’t get the role of the column data, which seems to drive your final outcome. Your explanation and the example is not very helpful.

For your understanding how java scripts has to be defined i added in the attached example the Column “target” in the source table and the calculation for the column “Extra” in the Java snippet. Comparing with the previous example you can see how the java snippet works.

Hi @newuser01,
what happens in the case that Extra equals null?
Please consider the depencense of the data and therefore the correct assignment (order of statements).
Run the java node and you’ll get the result and see whats happens.