Add index column with respect to group

Hi together,

it sounds pretty easy but I don’t know how to do it in Knime without using a Python node. I want to add a column which is a running number from 1 to infinity with respect to a group. For example when I have the table:

Group
23
23
34
56
23
34
23
56

It should add the following column

Group Index
23 1
23 2
34 1
56 1
23 3
34 2
23 4
56 2

Best regards
Armin

Hi @ArminFan,

the Rank node does the job.

BR

5 Likes

Hi @ArminFan , this can easily be done with the Rank node.

Here’s a sample workflow I put together:
image

Input data (same as yours):
image

Results:
image

Here’s the workflow:
Add index column with respect to group.knwf (9.6 KB)

9 Likes

Hi @bruno29a,

Thanks for your answer. Did not know that such a node existed, but that’s the easy solution I was looking for.

Best regards,
Armin

1 Like

No problem @ArminFan . You can play around with the Rank node and see the different results it gives, which might be helpful in the future.

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