Dynamic column lookup based on row value

Hi all,

I am new to KNIME and trying to understand how (if) I can migrate a process from Python to this platform. The goal is to see if I can move to a no-code solution. I have been searching the forum for a couple of days and it seems I might be able to do what I want with a Java snippet, but as I said, the idea is no-code. An additional constraint, on my work PC I cannot install extensions personally, so I am looking for an approach that uses only standard nodes.

Here is the situation. I have a dataset with a column that defines a KPI and based on the value in this column the KPI can be defined in different ways for different rows. Here is a picture to help illustrate.

knime

In short, based on the value in “SELECTION_VARIABLE” I want to create a new column “OUTPUT_COLUMN_I_WANT” that shows the variable I need for that row.

How can I do this kind of dynamic column lookup in KNIME?

Thanks!

Hi @cme0015 and welcome to KNIME Forum

Interesting question, I clicked some nodes together. I have the idea their might be a solution with fewer nodes, but at least this works, see dynamic_lookup.knwf (45.8 KB) , no python needed.


gr. Hans

1 Like

I borrowed @HansS great solution to build another solution

br

2 Likes

Thanks @Daniel_Weikert and @HansS both of these approaches look great. Looks like I have a lot to learn about KNIME!

1 Like

Hello @cme0015,

although you can not install extensions on your own I guess you can ask your IT to install it for you cause having Column Expressions node is definitely worth it. Among many powerful operations it can do one is to reference columns by its name and it’s one you need for this task to be pretty straightforward.

So following expression will give you exatcly what you want:
column(column("selection_variable"))

Welcome to KNIME Community!

Br,
Ivan

4 Likes

Hello all,
I am missing the ‘Rule Engine’ node solution:

$selection_variable$ LIKE "A" => $A$
$selection_variable$ LIKE "B" => $B$
$selection_variable$ LIKE "C" => $C$
TRUE => FALSE

BR

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.