Adding new column based on another

Hello,

I am trying to add a new column to my dataset that is based on the following row in the dataset. I have attached an example of the input data I’m working with and the desired output data for this example.

I have a series of ‘from’ data that is listed in a sequence based on record numbers. I want to add a new column called ‘to’ that takes the ‘from’ ID from the following record in the sequence and adds it to the preceeding row.

Any help would be really appreciated.

Thanks!
Example Sequence Link.knwf (8.2 KB)

Hi @zoe_knime,

I had a look at your data and it’s not quite clear what exact logic you want to apply.

Though, I believe this approach will suffice:

  1. Loop per record
  1. Use Lag column to shift the data
    Note: Sadly his node dos not support a negative value but I’ve got a fallback. Maybe you vote for this feature request?

Here is the possible solution:

Best
Mike

2 Likes

This is perfect, thanks so much Mike! and thank you for being kind with your response.

1 Like

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