How to distribute numbers from a table (Inventory) to another table (Customers)?

Hi, I am new using Knime and trying to develop a logical that can distribute numbers from table1 (Material#, inventory qty) to another table2 (Customer / Material# / Order qty) that is already in the priority order that should receive the inventory. So I want to distribute the available inventory from table1 from top to bottom of my table2, until it reaches to zero. After it gets to zero, then it should take the next material and run the same loop, till all matching materials are done.!

I am sharing below an example of so that it is easier to understand.

If anyone has any idea I would be more than thankful to hear!

Example%20Knime|689x177 Example%20Knime

I built something that does work - although it might not be the most elegant way to do it. The principle is first to group every product into a loop and then loop over each individual order. The tricky part is to ‘remember’ the quantity that is still in store after assigning a volume to the first order.

I did that by -well- just storing it into a table. I am not sure if KNIME can ‘remember’ a value or loop it back. So I just stored it and read it back. The table gets initiated for each product group. If you have very large volumes it might not be practical - but it does work and you might improve it further.

Also I put in a check to compare if the assigned deliveries match the inventory.

kn_example_order_inventory.knwf (99.2 KB)

2 Likes

Hey @mlauber71 !!! I was testing and adjusting it to fit in my current workflow and it is working perfectly fine !!!
I just needed to change the last joiner to a right outter join to bring all rows from the order list instead of only those that had inventory allocated.

Just tested with a small sample data and it took 2 minutes to process (around 6,000 rows), which is also good!

I will try to fine tune (And try to understad better what your workflow does) and improve it as I get more used to Knime (I started using this week :slight_smile: ) and will post here if any questions.

Thank you very much!!

Hi @mlauber71 . I was reviewing it further, and found that I need actually to have this same process, but for two different inventories. I am attaching below the example of what I would need.

In summary, would need to run the “distribution” process of the inventory into 2 different columns.

Do you know what are the changes I would need to do in the workflow so that it reflects this?

This is a modification with your example. I am not sure if your task always occurs like this delivering the same order about to two different locations, but so be it.

I would encourage you to explore KNIME further and try to solve problems with it so you will learn how to adapt it top your needs. Ofter there are several ways to do things and like all good programming it takes some planning and imagination what you want to achieve.

kn_example_order_inventory_2columns.knwf (101.5 KB)

3 Likes

This worked perfectly ( Again :smile: )!
And now I am getting more on how the workflow works.

Thank you very much @mlauber71 !

2 Likes