Hi coder, I need a code for that issue: I have column names, which contains the years 2020 down to 2000. And I have row values which contains the years 2020 down to 2000. The columns are filled with an Index. Now I want to multiply the row with the value i.e. 2003 with the value from the column 2003 or the row with the value 2018 with the index from column 2018. Sounds difficult but there should be solutions out in that wonderful community…
Hi @dibu: is the table a square (identical rows and columns)? you only work on the diagonal or fill the full table?
Hi Iperez, the table has about 30 columns, twelve of them are the years 2020 down to 2000. Every row has in one column a value which indicates the origin Year of the Numbers in that row. The column revenue should be the result from multiplying price with an amount and with the value in the column which has an index derived from column with the origin year.
Hi @dibu. If I understood you, your data looks like:
If it is so, this workflow does what you wish. Note that I’m using the node Column Expressions on the KNIME Labs, you need to have it installed.
COLINDEX.knwf (32.7 KB)
Hi Iperez, you are an undisputed genie! It works! I thank you so much! You are the best! THANK YOU!
nice one @iperez
You can also access column using other column’s value so following expression avoids loop and retains row order
price = column(string(column("ORIGIN YEAR"))) * column("QTTY")
Nice improvement! Thanks
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.