Make new column to count total duplicate

hello, I was make some looping process to count total of my row that have duplicate


image

the right table is what I have done in KNIME, but the output I want is the left table

Thank you

Hi @takdirzd,

You haven’t shown what your input table looks like or what you have done to achieve the result you currently have, but generally you would not need to use a loop for this.

You could achieve it using a GroupBy node to get the count of rows grouped by the column you are testing for duplication, and returning a count.

If your table only has one column you’ll need to add a dummy column as unfortunately GroupBy cannot count the same column it is grouping. Then if you want that count applied to each row of the original table as it appears in your image, you can join the output from group by back to your original table.

The above may appear a little vague and abstract because I don’t have details to use from your example, so here is a demo workflow which hopefully will better show what I mean:

Add counts to table.knwf (32.3 KB)

I have also included a slightly longer example where you might be using a duplicate row filter to find the non-unique rows and then return a table based on those:

Of course if you don’t really want the output table data rows repeated - I have only joined it back because that is how you had it in your example - , you can just stop at the “GroupBy” :slight_smile:

4 Likes

it works , thank you

1 Like

That’s great @takdirzd, and thank you for confirming this solution.

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