I need help calculating the stock amount of each product at the end of every month.
i’ve got a list of specific SKUs and its initial stock count at the beginning of the year, and another list grouping the sales amount.
The goal is to reduce the sales amount from the initial stock count and so on
here i’ve got the initial stock values at the beginning of the year (column estoqye)
and in this table i’ve got the sales amount of each month for each product id.
Hi,
You could join your two tables by SKU and year so that the stock at the beginning of the year is present in every monthly row. You can use a Group Loop Start + Loop End to go through every product and year individually. Now inside the loop, you can use a Moving Aggregation node with cumulative sum aggregation on the sales amount column and subtract this cumulative sum from the stock at the beginning of the year. So something like this:
Group Loop Start (group by SKU and year) -> Sort by month -> Moving aggregation -> Math Formula -> Loop End