Using dynamic flow variables as column identifiers

Hi there
I have a question which seems to be so obvious to be possible that I guess I am just not really finding the right spot where it is described.

I have a workflow in which I create a dynamic variable using a java edit variable node. This flow variable is used later to create a column with this dynamic variable name. When I want to use this new column in the rule engine it seems as if I cannot use it since the flow variable itself is not a column. Here is an example to better describe what I am doing:

I start by defining the variable as such
varName = “myValue”

then I create a column which is called “myValue” by using the varName flow variable.

What I now want is to access the dynamic column that was created (which is of type double) in the rule engine - but $${myValue}$$ is of course not working.

Is there a way to “interpret” the value of varName so that then the respective column can be accessed in the dialogues?

Since this is a functionality that would be interesting for multiple nodes I guess it must be possible and if not it would be an interesting extensions.
PS: I am aware that I can resolve the issue by not using dynamic variables throughout the process but static columns that are renamed at the end of the workflow to the dynamic name but this is in my opinion not what makes sense (I wouldn’t do it in things like pandas or similar so why here).

Well this is AFAIK the only solution and that is what I do. dynamic column names can be a PITA in KNIME.Best to only assign the dynamic name before showing it to the user. There really is no downside to that.

1 Like

Hi there!

It seems that in Rule engine node this is not possible. But you have Column Expressions node in which you can access column based on flow variable value.

The syntax and grammar of the expressions in Column Expressions node are based on the JavaScript Language so you can write your rule(s) :slight_smile:



I am not sure if I understand that 100%. It seems a lot of things are possible with dynamic variable names. If I have more complicated loops and calculations with dynamic variable names I often 1st rename them to a standard variable name (like “_temp_var”) and make all the calculations and transformations using that and in the end rename the result back to the original name or a changed version of it.

Not sure in which kind of dialog the variable should appear. Maybe you could give us an example.

my_variable1 -> _temp_var -> (all the manipulations you want) -> my_variable1_new

The workflow below tries to do some stuff while using the column names as variables.

kn_example_dynamic_workflow_variables.knwf (21.7 KB)

1 Like