Row/Column Manipulation

Hello, I got a table with the volumes per project per year after start (0, 1, 2,…)

I would now like to get a table with the volumes per calendar year.

ID Start 0 1 2
x 2020 4 5 2
y 2019 1 3 4

–>

ID 2019 2020 2021 2022
x 0 4 5 2
y 1 3 4 0

Is that possible?

I don’t even know how to start…

Regards,

Sepp

I know, I shouldn’t reply on my own post…

I found a time consuming way.

First I filter every Start Year, then I rename the columns and concatenate the tables.

That gives me a table in the way I was looking for (or it looks like the way I wanted it to be)

My question now: Is there a leaner way on doing so?

Regards,

Sepp

Hi,

what do you think about this workflow?

BR
Hermann

DEMO.knwf (26.1 KB)

4 Likes

That’s a lean methode to perform the task, much nicer than my way.

Thanks

1 Like

Hi there @Sepp_Bauer,

welcome to KNIME Community!

Well you can try some scripting node as this task seems appropriate for it. For example Column Expressions node can help you with following code:

switch(column("Start")) {
  case "2019":
    arrayCreate(column("0"),column("1"),column("2"),"0")
    break;
  case "2020":
    arrayCreate("0",column("0"),column("1"),column("2"))
    break;
  default:
    // code block
}

which creates collection column in order you need based on your start year. Then simply use Split Collection Column node to have values in separate columns :wink:

Br,
Ivan

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