Assign group ID for rows

Hello all,

is it possible to assign group ID to the row of a table without scripting as in the following example?

Item GroupID
A 1
A 1
A 1
B 2
B 2
B 2
C 3
C 3
A 4
A 4
D 5
B 6
B 6
C 7
C 7
C 7
D 8
D 8
D 8

Or, should I use a Java/R/Python script for that?

Thank you in advance!

Roland

Hi @rolandnemeth

Yes that is possible, see this workflow groupids_for_rows.knwf (46.7 KB)
gr. Hans

2 Likes

Hello @HansS, it solved my problem! Perfect!

Meanwhile, I figured out an other solution and implement it in yours, please find attached the workflow.

groupids_for_rows (2).knwf (29.4 KB)

2 Likes

Hello @rolandnemeth,

here are two more ways. Only scripting (I see you wrote you are looking for a solution without scripting but then used both Java and Column Expressions in you workflow) using Column Expressions and one outputting RowIndex when change detected in Rule Engine together with Missing Values to have same id in every group followed by Rank to complete it.

groupids_for_rows_ipazin.knwf (29.4 KB)

Probably best way for this is to use only Java…

Br,
Ivan

2 Likes

Hello @ipazin thanks for your answer, solution.

Yes, I made a mixed solution with Java snippet and column expression, I am new in KNIME and do not know everything, but tried to solve the problem meanwhile, that was the result workflow. :slight_smile:

1 Like

If you group it, add a number and then join on the original that should work too. Maybe too many steps

1 Like

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