Variables in Knime Expression

I am looking to have an intermediate variable within the Expression window.

As you can see in the screenshot, the declaration of a variable is not supported. Is it supported at all?

var pos = find($[“Iteration”], “DG-”) ← This does not work… Also INTEGER pos or without var did not work.

Hello @mbrenn ,

the expression node supports exactly one expression returning one output value, like switch(…) in version 5.3. You cannot enter multiple expressions like switch(…) ␤ find(…). One possible alternative is to use a chain of multiple Expression nodes. Another one would be to use, e.g., a Python Script node for more complex calculations.

In version 5.4 – to be released in the beginning of December – the node is going to support multiple expressions, each appending/replacing a column. We thought about adding support for temporary columns/variables that are not part of the output, too, but so far concluded that this is not crucial. Your feedback is welcome.

Have a nice day,
nan

4 Likes

Thanks a lot.
Issue is that the same calculation needs to be done multiple times.

Using helper columns help (or the “Column Expression” node which supports a JavaScript-like syntax).

Looking forward to 5.4