Re-Arrange multiple columns

Hello fellow KNIMErs,

I have the following table:

company location order no order date shortterm order qty short order date longterm order qty long
Company Ltd Somewhere 1 14.02.2022 1 01.06.2022 100
15.02.2022 2 01.07.2022 200
16.02.2022 3 01.08.2022 300
17.02.2022 4 01.09.2022 400
Company Ltd Somewhere 3 01.03.2022 9 01.10.2022 110
02.03.2022 8 02.10.2022 220
03.03.2022 7 03.10.2022 330
05.10.2022 550
06.10.2022 660
Company Ltd Somewhere 5 01.10.2022 120
02.10.2022 130
03.10.2022 140
04.10.2022 150
Company Ltd Somewhere 6 01.03.2022 1
02.03.2022 2
03.03.2022 3

I would like the last 4 columns to be under another to look like this:

company location order no order date order qty
Company Ltd Somewhere 1 14.02.2022 1
15.02.2022 2
16.02.2022 3
17.02.2022 4
01.06.2022 100
01.07.2022 200
01.08.2022 300
01.09.2022 400
Company Ltd Somewhere 3 01.03.2022 9
02.03.2022 8
03.03.2022 7
01.10.2022 110
02.10.2022 220
03.10.2022 330
05.10.2022 550
06.10.2022 660
Company Ltd Somewhere 5 01.10.2022 120
02.10.2022 130
03.10.2022 140
04.10.2022 150
Company Ltd Somewhere 6 01.03.2022 1
02.03.2022 2
03.03.2022 3

I have been messing around with different nodes, but it doesn’t look promising.
Is there a simple way to achieve this result?

Thanks.

@gentile

One solution that comes to mind:
Uee from the original table two column filter nodes Column Filter — NodePit to create two tables which contain the relevant columns.
In your case
Filter 1: Company, Location, Order Date Short, Qty Short
Filter 2: Company, Location, Order DateLong, Qty Long
Rename the columns in one table 2 to the same names like in table 1 using the
After that make a join using the Concatenate Node https://nodepit.com/node/org.knime.base.node.preproc.append.row.AppendedRowsNodeFactory?numWorkflows=999999 that’s joining on Company and Location.
If required you can filter out “empty” entries on Qty

4 Likes

Thanks for the suggestion. It gave me an idea in which direction to go.

I ended up joining the 4 columns with ColumnExpressions into 2: “order qty short | order date short” and “order qty long | order date long”, so that I would be left with only two columns to deal with. Then with a “Column List Loop Start”, “Loop End” and “Column Combiner” combined them into one column. At the end I split the values with a “Cell Splitter” into two new columns.

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