Coluna Condicional

Hello everyone! I need the following help: In Knime, I have a table that contains 1 column targeted by this question. This column is called “UEP”. In it I have values, not distinct, which are: P-66, P-67, P-68, P-69, P-70, P-71, P-MXL and P-MLZ. I need to create a new column that returns values ​​under the following conditions:

If the UEP column is equal to P-66, the new column must have the values ​​4419 and 4419-P66M;

If the UEP column is equal to P-67, the new column must contain the values ​​4419 and 4419-P67M;

If the UEP column is equal to P-68, the new column must contain the values ​​4130 and 4130-P68M;

If the UEP column is equal to P-69, the new column must have the values ​​4419 and 4419-P69M;

If the UEP column is equal to P-70, the new column must have the values ​​4128 and 4128-P70M;

If the UEP column is equal to P-71, the new column must have the values ​​4143 and 4143-P71M;

If the UEP column is equal to P-MXL, the new column must contain the values ​​2413;

If the UEP column is equal to P-MLZ, the new column must bring the values ​​2413.

But one in each line. It will increase the number of rows in the table, of course.

Help me, how to do this?

Hey @rodolphovieira,

If I am understanding correctly, in the column UEP, you want to replace the value such as ‘P-66’ to ‘4419’ and ‘4419-P66M’, also you want them to be in separate rows.

You can try to use a ‘Rule Engine’ node based on the parameters you listed above as you have your necessary conditionals already laid out.

For example, when you run into ‘P-66’, you can output a ‘4419,4419-P66M’ as a string (as I do not believe the rule engine node is capable of outputting a list). After this initial processing is done you can connect a ‘Ungroup’ node on the modified column to split them into two separate rows if they have more than one value.

Here is a sample on how you can do it:
gif

  1. Use a rule engine and convert your UEP column.
  • For example: $UEP$ MATCHES “P-66” => “4419,4419-P66M”
  1. use cell splitter on ‘,’ as delimiter and output as LIST
  2. use ungroup on LIST

Hope this helps,
TL

2 Likes