How to update a table in a loop every iteration

Help Needed!
I’m working on a solution of looping to split inbound demand (By truck) to current inv table.
So, two inputs here, inbound demand (by truck by SKU), inv table (By SKU):
Inbound Demand:
Inv Table:
Processing Logic:
Step 1. By truck to start calculate, which here I use group loop start for next calculation from Inbound Demand;
Step 2. Calculate with Inv Table, whatever is just processing logic but need to engage inv table refreshed, to judge the Loc Column;
Step 3. Put the new demand add into Inv Table of related Loc, then update the inv table;
Step 4. Jump to next generation, new truck with new inv table;

Base on my needs, I drafted the model like below, but obviously wrong~

Anyone here could help me on this? Very appreciate!

Best Regards.

Hi @Vincent_liang and welcome to KNIME Community Forum,

I’m not sure if I have understood your problem perfectly. How about an example input and and your desired output? It usually works the best here.

Input Example just like the two tables showed above: Inbound Demand & Inv Table;
Inbound Demand:
Inv Table:

Process Logic:
Just simplified: prefer OSWH first, when demand + inv by loc over 100, left move to another loc. Then define each loc volume percentage by truck (etc. OSWH Volume/Truck Qty), once >50% then judge the loc~
*Note: OSWH Volume + MAIN Volume = Truck Qty

Expected Output:
For Inbound Demand, I need to add Loc Column for each truck, like this:
For Inv Table: I need the updated version after last iteration, the

How do you know that the “Loc” for inbound demand table is “main” or “OSWH”. Is it something like separate files or sheets for each “Loc” value?
Since you have added the sum of inbound demand of each SKU in the inbound demand table to the corresponding SKU with Loc of OSWH in the Inv table, I guess the whole inbound demand table here refers to OSWH, right?

I do not believe your loop structure will work. You can build nested loops to ensure each loop has its dedicated “cycle”

Actually, we have set inv cap by loc by SKU. For each truck, we follow the cap guidence to calculate the cap hit rate, before we deside to chose whether to main of oswh.

Yes, you are right. Obviously, it’s not working. May I get your suggestions about nested loops, I have tried to build that, but failed~

@Vincent_liang two things. If I have to use intermediate results and read them back I often just store them in a file that has been created before the loop start.

Yes not the most elegant solution but I like it and one might even construct a loop that could start where it left in case of a crash.

Concerning your problem. It might be best to create an example you chould share that would present your challenges and also edge cases. Very much data for a case, no data and so on.

And define what the ‘rules’ and the outcome is.

Then the forum could work on the problem in the form of visual code.

I have spent hours and hours thinking about the logics and concepts off business requirements. That is the hard part. Doing the program is easy :grinning: (ok sort of). And thanks to KNIME you can see what is going on in very step of your way.

1 Like

@mlauber71 Super thanks for your suggestion.
Loop to update a table.knwf (105.6 KB)
Here is my demo, like below:

This is my first time to use the forum, I should know the rules, better to upload the demo at the first time, thx for your effort behind~ Very appreciate, could you further help me on this based on my demo, thx~

@mlauber71 Bravo!!! Big appreciate for your input on intermediate result storage solution! It’s worked!

My final outcome is what I expected:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.