Icon

Inventory Cover

This workflow demonstrates the usage of a recursive loop for inventory cover calculation.
The algorithm calculates the cover for an inventory. For each week, we have end inventory and consumption and calculate the number of weeks the end inventory lasts.

We do this by going through the table row by row and each time:
- We check if it is the last row. If yes, we return 0.
- Otherwise, we take the cumulative sum of the consumption in the following weeks and
- count the number of weeks the inventory lasts.
- If at the end a fraction is left, we calculate that as well as (end inventory - consumption until then) / consumption of next week

Annotations and comments
  • This algorithm calculates the cover for an inventory. For each week, we have end inventory and consumption and calculate the number of weeks the end inventory lasts. We do this by going through the table row by row and each time: - We check if it is the last row. If yes, we return 0. - Otherwise, we take the cumulative sum of the consumption in the following weeks and - count the number of weeks the inventory lasts. - If at the end a fraction is left, we calculate that as well as (end inventory - consumption until then) / consumption of next week
  • Top: first iterations Bottom: last iteration
  • Last iteration?
  • dummy
  • If last iteration, cover = 0
  • we need the number of rows
  • rename consumption sum column
  • #rows + next consumption / (inventory - consumption_sum)
  • Cumulative sum of consumption
  • Only where cum_sum(consumption) < end_inv
  • Send back data without first row Collect rows with cover
  • First row vs rest
  • Example data
  • Ending Inv needed for row splitter
  • Add cover

Nodes

Extensions

Links