Rename in Lag-Node or Rename by Position

I am using the Lag Column Node to get lag values.

The problem is that I have to rename the column to fit to the naming conventions AND I do not know which column gets lagged since this is controlled by a Column Selection Configuration node.

  • If there would be a rename config within the Lag Column I could use this (=> Feature Request)
  • If there was any way to rename a column by position, I could do the renaming directly after producing the lag since the lag column is always appended to the right of the table - Is there a way to rename by position?

I found a workaround using

  • Extract Table Spec and
  • Sorter and
  • Table Row to Variable and
  • Column rename

Hi @petermeissner,

Not sure about how useful would this be. If Lag parameter is higher than one then you have same need to rename columns after it.

This approach makes more sense in my opinion and you can do it by using Column Expressions node with following syntax:
column(numberOfColumns() - 1)

Check replace column and control new column name with flow variable. Should work.

Additionally use String Manipulation (Variable) node to add “(-1)” to lagged column name to create new flow variable name column name you wish to rename.


Jip, this would only work for one column. But would be enough for 99.5% of use cases - and I could propably do a 5 times loop if I want 5 loops and could still rename the columns however I want. E.g. adding ‘(-1)’ as suffix is never an option anyways.

This kind of works not.

Now, I have a copy of the column named however I like but than what to do with the original? (Besides, producing the copy takes considerable time.)

Hi @petermeissner,

check workflow attached. There you’ll find what I have meant with adding “(-1)” in upper flow and in next flow you can see how to solve this with renaming column which is to be lagged prior to lagging. Hope one of these solutions will work for you.

rename last column_ipazin.knwf (38.9 KB)

Regarding Column Expressions solution that wasn’t the best idea and will not work :sweat_smile:




The second flow really looks nice - very straight forward and less convoluted than my workaround. :+1:

So, we now have three ways to solve this:

  1. Use “Extract Table Spec” and “Table Row to Variable” to get the name of the last column to set up old_column_name and new_column_name as flow variable config

  1. Use the information (a string) from “Column Selection Configuration” to manipulate the name of the original column such that it matches the new lag column name

. . .

  1. Use the information from “Column Selection Configuration” to first rename the selected column to something we know and later on after doing the lag rename

1 Like

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