lag column -1

hi i would like to lag a row to the top and not to the bottom. I tried -1 but it doesn’t work.
ty for help

Hi @aurelienchauvin, the lag node only works in one direction so to “reverse” the lag operation, what I do is first sort the table in reverse order. (if there is currently no suitable ordered key, then first of all add a sequential key column using a Counter Generation node and sort descending using the counter).

After sorting, perform the Lag Node as before and then sort the table back to the original order.

4 Likes

Hello @aurelienchauvin
You can take a look into to the following topic:

‘Column Expressions’ would be the alternative node to perform this task with the offset() function. With checked ‘Enable multi-row access’ and ‘Use null’ (?) for prior. after first last row…

column("target_column", 1)

BR

5 Likes

thank you it’s a good idea but i don’t find counter generation.

Hi @aurelienchauvin

Drag and drop the node from the KNIME Hub


And it wil be installed.

Or use the Math Formula node:

gr. Hans

3 Likes

thank you for answer, I found this solution.
regards

1 Like

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