I new to Knime and still struggling with the node structure. I have a code in my head where I wish to create two new columns, both based on if/else statement. Also I would like to store values beforehand in variables without actually creating them. Also I would like to do that with as few (preferably one) node as possible.
I wanted to use the “Column expression” but I get an error message that "temp_var"is not defined even though i define it in the first row.
and the second expression looks similar. I know you can probably do that with java_snippet node but is it also possible with the column expression? Because it should store the values assigned to the temp-var1 and temp_var 2 variables right?
Excuses if a question like this was already asked, I could not find it.
You have to add two expressions in the top half of the configuration, one expression for each column. In the bottom half you define the expression. By clicking on the expression in the top half, you will get its expression in the expression editor.
As you will see I moved the definitions of tempvar1 and tempvar2 to the else-branch, simply to avoid these calculations might go wrong (give an unwanted error) if either one of the columns is missing or the division should be done through zero.
Maybe that’s what caused the error you mention?
The second expression is not so fancy as the above one. It’s just an example…
I think I will start using this node more often, because till now I used often a combination of several other nodes to achieve the same result.
So thanks for asking your question as it will help me in the future too
Just keep in mind that the node is very slow. No problem if you work with a couple of thousand of rows, but if you want to work somewhat interactively with 100k or millions of row, the waiting gets old very fast.