Hi Friends,

I would like some help.

I’m creating this workflow to calculate the product consumption from Selling and return.

**Explanation:**

I have a selling product table with return values. (BLUE)

Selling values is positive, and return is negative

I have another table that shows the initial values that the company have in Stock por each product. (ORANGE)

I create a Group loop start to iterate over product and JOIN (PINK) with the 'initial" table values, to only show 1 row and then use the table row to variable

**What i need!!**

I need to iterate and calculate the **historical** value starting from initial stock by -_id_product **util** the last Invoice.

*See green colum for result*

Talking about variable, is like I need to overwrite the initial value after de first iteration and store that value to use it again for the next iteration and so on.

Example:

Iteration 1

initial_value_variable é equal = 5

Then, invoice is -1 = Then SUM initial_value_variable + -1 = initial_value_variable = 4

Iteration 2

initial_value_variable é equal = 4

Then, invoice is 1 = Then SUM initial_value_variable + 1 = initial_value_variable = 5

My initial values needs to be dynamic

Moving aggregator_Initial_Values.knwf (28.3 KB)