Mulitple rows with unique ID combining in one row

Hi there,

I’m new to KNIME and struggle probably with an easy to solve problem. Although I have not seen any query with this problem.

I have two input tables with various rows all having the same unique ID but different content. I would like to have one row per ID combining all data sets either in one column (output #1) or on mulitple ones (output #2).

Example: I have two tables that contain identical unique ID’s but different content. I want merge them into one row with all combined content.

.knime_multiple_rows01

It’ll be great if some of you could point me to a solution.

Many thanks in advance

@knickmanns Welcome to the forum!
I don´t know if this is the simplest way to do it.
Create a table like this:
imagen
and then use the pivoting node. This gives:

pivot node.knwf (18.9 KB)

1 Like

What @iperez suggested here is what I was thinking of.

Also, for the second operation to generate a comma separated string, take the pivoted values generated above, clean them up a bit, and use the Column Combiner node. Or alternatively, implement the Create Collection Column node if you prefer a collection.

1 Like

concatenate and group by nodes should also work
bR

1 Like

Hi Daniel,

I tried your proposal but did not make it work.

How can the groupby node write the “value” column parameters from different rows in one column or separate ones?
With concatenate and groupby it looks like this.

|DO0001|HUA4G|LA1|
|DO0001|HUA4G|LA2|
|DO0001|HUA4G|LA3|
|DO0001|HUA4G|LB1|
|DO0001|HUA4G|LB2|
|DO0001|HUA4G|LB3|
|DO0001|HUA4G|LK1|
|DO0001|HUA4G|LK3|
|DO0001|HUA4G|LU1|
|DO0001|HUA4G|LU2|
|DO0001|HUA4G|LU3|
|DO0001|HUA5G|GU1|
|DO0001|HUA5G|GU2|
|DO0001|HUA5G|GU3|

Aim is to have it like:
|DO0001|LA1, LA2, LA3, …GU1, GU2, GU3|

Many thanks in advance

Many thanks for you help and the pivot node. Still I can’t make it work. I haven’t found out what the auxilar shall do.

The pivot node requieres at least three different variables to work: One for creating the groups (rows=id), one for the columns (here is where you use the auxiliar column, one for each value) and one to do the aggregation (in this case your “value” attribute).

In the second tab of the groupby node you should be able to specify the aggregation type
bR

Hi Daniel,

it finally worked. Many thanks. The groupby node also offers the perfect filter to unique entries.

Br,
Stephan

Great thanks for your update.
BR

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