How to replace multiple values in different columns

Hi everyone,

I need your help for a new issue with Knime.

I am trying to replace multiple values for each columns according to a corresponding table.

Maybe, it’s not clear so i give you an example to illustrate my idea.

So I have my datas like this :

Individu Color cars Statut Job
1 B D Acc
2 Y M Man
3 G S lyer
4 BL D bkr
5 R M dst
6 WH D nrs

So I Would like to replace this values with others values from an other table :

Variable Value Value to change
Colors cars B Blue
Colors cars Y Yellow
Colors cars G Green
Colors cars BL Black
Colors cars R Red
Colors cars WH White
Statut D Divorced
Statut M Married
Statut S Single
Job Acc Accounting
Job Man Manager
Job lyer Lawyer
Job bkr Baker
Job dst Dentist
Job nrs Nurse

But I don’t know how to do this.

Check out the “Column Expressions” node and the replace function within it.

@Snowy Thank you for you answer.

I have checked the " Colomn Expressions " node but I don’t think I am able to use it.
I have any knowledge in java programming.

There is no a simple way to do this ?

Hi @Grayfox,

To make use of the Column Expressions node in this case, you need a loop. Here I have a solution without loops:

value_change.knwf (31.8 KB)

I have used an Unpivoting node on the first table and then joined two tables and finally used a Pivoting node to create the desired output.


P.S. Here is a blog post to learn more about the Column Expressions node:


Hi @armingrudd

I tried your solution and It’s working. Thank you so much.

I also tried an other solution with looping others columns and using the Cell replacer Node to replace with the values that I wanted.
Finally it’s not working when I use the loop, the values are replacing but not with the good one.

1 Like

And just for my curiosity, how i can do with a loop and the Cell replacer node.

In my example If I have duplicate values to change in differents variables, but it’s not replace with the good value from the good variable.

For example if I have

Individus Colors Cars Statut Job
1 B D A
2 Y M M
3 G S B

And i want to change the value with this table

Variable Value Value to change
Colors Cars B Blue
Colors Cars Y Yellow
Colors Cars M Marron
Job B Businessman
Job M Manager
Statut M Married

The replacement is wrong, it’s not replace with the good value from the right variable :

Individus Colors Cars Statut Job
1 Blue D A
2 Yellow Marron Marron
3 G S Blue

I’ve got the value " Marron " in the statut column, so the replacement not take the good value from the variable statut.

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