I have a table with columns like Var1, Var2, Var3…Var10 and I also have some value in columns like Var1_coeff, Var2_coeff,Var3_coeff…Var10_coeff. I want to multiply and creates columns like Final_Var1, Final Var2…Final_Var 10 by multiplying corresponding columns
Final_Var1 = Var1 x Var1_coeff
Final_var2 = Var2 x Var2_coeff
Final_var10 - Var10 x Var10_Coeff.
I can achieve this task using Column loop, rename flow, and R snippet. However, I want your help in if I can do this exercise with existing nodes and in a more natural way.
Hi @Jyotendra -
Have you tried the Math Formula and Math Formula (Multi Column) nodes? These might get you where you need to go.
As far as I understand, Multi Column Math Formula does a single operation on multiple operation. For e.g, if I needed to do single operation with multiple column than that would this node would have been useful.
however, my challenge is to do different operation with different columns. that is where I am struggling.
I tried to set up da workflow where you have a ‘system’ of Variables and Coefficients that are identified by their name “Var1” and and addition of “_coeff” like in your example. The workflow is flexible so that it would take any number of columns of that structure and combine them (multiply in my example). If you know the operation maybe you could also put that in a variable and construct a formula with a simple Java Snippet within the loop.
For the loop I have only found the solution to rename every variable into a standard name, use the Math node and then name it back.
Maybe you could have a look at that and try to expand.
If you have sort of a ‘fixed’ environment of variables and operations you want to do, or it would not change that much it could be an idea to think about a Java Snippet that would do that.
kn_example_multiply_multiple_col.knwf (93.1 KB)
Thank you. A good working solution.
However, if I wonder that for doing an operation like
"(For i=0, n, i++)
_ Fi_nal_var_i=Var_i * Var_coeff_i "_
you created an lengthy workflow and I was clueless on how can we achieve it
I should look into the quite new multiple math column node if it can handle patterns of columns or one can create flow variables to handle that. Then it could be that the workflows could be simpler and would not require a loop.
Also a Loop or apply in R could be possible. I am not sure how the Java Snippet node would Handel a loop.
Loop in R is possible because I have already tried it. I am not sure about Java snippet.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.