Hi everybody! I need to calculate growth rates for multiple columns in different context. A first try was using the LAG COLUMN node for the period column, then connect with a joiner both of tables, after I use a “column expressions” to calculate the growth rates of each column in the table.
BUT, what if I have a lot of columns? Is necesary that I write all the formulas in the column expressions? Does anyone have another solution for this?
Growth rates example.knwf (39.4 KB)
Growth rates.xlsx (8.5 KB)
Welcome to the KNIME Community!
Below is an alternative dynamic approach that does not require any hardcoded work and can be used for an unlimited amount of columns.
It works with the Column List Loop, that will iterate through all the Country columns. You can set this by the enforced exclusion of Period, meaning any additional Country columns will be included automatically.
If you like, you can do the lag and calculate operation in one go in a Column Expression by using
column(variable("currentColumnName"),1) / column(variable("currentColumnName")) -1
Under Advanced, make sure the Multi-row access feature is enabled.
The great thing about the Column List loop is that it keeps track of the current column in a flow variable.
The previous calculation statement makes use of this and also the column to update in the Column Expression can be controlled via this.
After the loop you can perform a small clean-up to get rid of the additional Period columns.
See WF:
Growth rates for multiple columns.knwf (31.8 KB)
Hope this helps!
Thank you very much! It’s exactly what I need
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.