Compare duplicate key value with condition

Hello KNIME Experts,

Hope you all are doing well.

I am new to KNIME and I am stuck with below issue.

I have two tables as below, Table B is sort by date, and two tables have the duplicate Material number, if Table A.Material (first) = Table B.Material, till A.Quantity - B.Quantity <=0, fill in the corresponding date in Table A, then the calculation of Table A.Material (second) starts with the balance of the last one.

Column E is the calculate logic if my description is not clear.

I appreciate any help.

@Chupas welcome to the KNIME forum. I fear I do not completely understand your logic.

Maybe you could provide the data instead of a screenshot and do a morde detailed explanation of the logic. And also take into account if there are different scenarios (more Material numbers).

And from a quick check I do not understand on the right side how you come about the numbers if there should be a ‘countdown’ to zero?

My advise would be to think thru the logic and come up with a more detailed description, maybe set out the rules a bullet points so it is easier to follow and explain one example in more details.


Hi @Chupas and welcome to the Knime Community.

I think I understood what you are looking for, I was able to follow what you have in E, but you should help come up with the logic. I mean, regardless if you were not doing this in Knime or not, how would you define the rules?

There is a cumulative aggregation involved per Material, but it’s kinda mixed by date. The logic needs to be clearly defined in order to implement it.


Hi @Chupas , I put something together for you.

I extended the sample data to include 2 Materials, and also more than 1 case of 0 quantity. Sample data looks like this:
Table A:

Table B:


The workflow looks like this:

Here’s the workflow: Compare duplicate key value with condition.knwf (31.0 KB)

All of the logic to assign the values is done via the Java Snippet. I borrowed that Java Snippet from one of @takbb 's reply in another thread (This is similar to assigning budget to transactions).


Hi @bruno29a,
Thanks a lot!
There are some difference with my expected output as my explanation is not clear.
But I found the solution which you mentioned in @takbb 's reply (Allocate txn to budget 2.knwf).
It works after I change the left- right relationship of two tables.
Thanks again.


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