Data Manipulation with Sets

Table Name Set Cumulative Set Change Added Joining
Table 1 A,B,C A,B,C TRUE A,B,C ?
Table 2 B,C,D A,B,C,D TRUE D B,C
Table 3 A,B,D A,B,C,D FALSE ? ?
Table 4 E,F A,B,C,D,E,F TRUE E,F ?

Let’s say we were given Table Name, Set and we want to calculate: Cumulative Set, Change,Added and Joining. How would you go about that?

Cumulative Set adds anything to the SET that doesn’t exist.
Change is to measure if anything was added or not.
Added tells us what is added.
Joining tells us what is all the keys that exist in current set and previous cumulative set. (If Change is false this is null)

Why I ask I am not sure how programmatic global variables work in Knime.

I think you could use recursion to do that:

However the “global variables” which you want to have for this… do not exists (would make some things easier)
You could use the JavaSnippet Node instead (as you can keep a variable through each row step here)

I think Java Snippet is the easiest solution here, however I think the recursion is also doable if you want to do it without coding :slight_smile:

1 Like

I used the Moving Aggregation node that way you don’t have to loop or worry about global variables.

3 Likes

Thanks for your solution :slight_smile:
Didn’t know about the moving aggregation node - great to know :+1:

HI there @shubhamss,

nice one! I’m interested so if you don’t mind could you share workflow example for data given in first post?

Br,
Ivan

2 Likes

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