How to convert rows to columns

I have a table below: (col 1- 4). I want to create a 5th column based on value column…expected output is as shown below

id order_id value amount expected value
1 id1 mobile 1000 mobile, laptop
1 id2 laptop 2000
2 id3 accesory 3000 accesory

What nodes should I use to transform the value column

Hello @amirkhan123,

and welcome to KNIME Community!

If I got it right you need to do Grouping based on id column where you want to concatenate value column and then bring it back as new column but only for first entry in a group. If that is correct you can use Group By node where id is your grouping column and in aggregation methods you need to use First on order_id and Concatenate on value. Then use Joiner node on id, order_id to bring concatenated values to original data.

Hope this gets you started.


1 Like

HI, Thanks for the response.
Grouping is fine, however how do I get the value column to show “mobile,laptop”.
I need to convert rows to columns by concatenating column values

Narrowing down the q:
id value
1 mobile
1 laptop
2 printer
2 acc

Expected output:
id value
1 mobile,laptop
2 printer, acc

if you need to convert them to real columns then pivot node
If you just want one column with comma seperated values then as @ipazin said use groupby and as aggregation concatenate with “,” seperator

1 Like