Hello Knime Experts,
I need some suggestions on how I can perform this iterate on KNIME.
I am thinking add index would be the go-to but I cannot wrap my head around a formula. Hoping that someone can share their knowledge.
The Algorithm set:
Initialization:
NET = ORD QTY
Virtual Backlog = ORD QTY – DELVRY QTY
Remaining steps:
NET = (NEXT) ORD QTY – Virtual Backlog
IF (NET DEMAND < 0)
NET DEMAND = 0
Virtual Backlog = NET + Virtual Backlog - DELVRY QTY
Defining a variable “previousVirtualBacklog” in the “Your custom variables” section allows the value of the variable to be remembered from one row to the next.
// Your custom variables:
int previousVirtualBacklog=0; // this will be remembered for next row
The rest of the code is basically a simplified version of your algorithm, written in java:
// Enter your code here:
// NET = This ORD QTY - previous VIRTUAL BACKLOG (which is zero initialisation)
// IF NET < 0 THEN NET = 0
// VIRTUAL BACKLOG = NET - DELIVERY QTY + previous VIRTUAL BACKLOG
out_Net = c_Order - previousVirtualBacklog;
if (out_Net <0 )
{
out_Net = 0;
}
out_VirtualBacklog = out_Net + previousVirtualBacklog - c_Ship;
// remember the "previous virtual backlog" for next row
previousVirtualBacklog=out_VirtualBacklog;
@takbb Thank you so much for the quick response and sorry for the confusion on different name. But your assumption is correct
This works.
However, my bad i forgot to add another requirement is *ITERATE through all records for each combination of SKU, Door and Date.
=> “previousVirtualBacklog" should be reset to 0 when I have a new cobination of SKU, Door and Date.
Hi @bbui226 , the simplest way of fixing that is to put the Java snippet inside a group loop (so just add a group loop start and a loop end either side of the snippet, and have the group loop configured to group on the set of “combination” fields you mentioned.