New column, if, then, filter?

Hi all,

I’m quit new to knime and would need some help. Please check my screenshot:

image

I have an existing column E “Code”
I would like to put in the Column F “Account” the following rules:

If E = “L77” then put 667901
if E = “B*” then put 603000
and in the other cases put 64733.

Any ideas how to realize that best?

Thank you in advance.

BR
Markus

2 Likes

Hi @Markus3003 , this can be done with a Rule Engine node as follows:
image

And the rules you would use are:

$Code$ = "L77" => 667901
$Code$ LIKE "B*" => 603000
TRUE => 64733

$Code$ is basically your column name “Code”
$Code$ = "L77" => 667901 means if value of column Code = “L77” then return 667901
$Code$ LIKE "B*" => 603000 means if value of column Code starts with a “B” then return 603000
TRUE => 64733 means if none of the above conditions applied, return 64733, which basically means it’s the default value.

And since I use the option “Append Column” with column name “Account”, it will create a new column Account and add the returned values to it.

Results:
image

Here’s the workflow: New column if then filter.knwf (6.7 KB)

4 Likes

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