column expression node to trigger functions

good morning

I try to use the column expression node to trigger the following function but I can not get it to run…
if (column(“mailtyp”)) == (“emailA”) =>
string (column(“LowFirstName”),".“column(“LowLastName”),”@",column(“Email_Arr[1]”))
else if (column(“mailtyp”)) == (“emailB”) = string (column(“LowFirstName”),"_“column(“LowLastName”),”@",column(“Email_Arr[1]”))
else “none”

as an uglyworkaround I had to use various rule-based row splitters then string manipulations and finally concatenate it…

maybe I need to loop the whole thing…

any hints welcome…

thnx and have a great day!

Hi @adaptagis,

Put the whole condition in parentheses:
if (column(“mailtyp”) == “emailA”)

Use “join” function instead of “string” function: (and use string function to convert numeric columns to string)
join(column(“LowFirstName”),".",column(“LowLastName”),"@",column(“Email_Arr[1]”))

Do the same for the “else if” statement and it should work fine.

:blush:

3 Likes

thank you Armin!
I will do as said… and give feedback!

1 Like

hello again!
I’m a step closer but still not there…
Errors in code. Please fix the expression.

if ((column(“mailtyp”)) == (“emailB”) => join(column(“LowFirstName”)),".",(column(“LowLastName”)),"@",(column(“Email_Arr[1]”)))
else if ((column(“mailtyp”)) == (“emailB”) => join(column(“LowFirstName”)),"_",(column(“LowLastName”)),"@",(column(“Email_Arr[1]”)))
else “none”

error:
Expected an operand’ but found 'else ’
else if ((column(“mailtyp”)) == (“emailB”) => join(column(“LowFirstName”)),"_",(column(“LowLastName”)),"@",(column(“Email_Arr[1]”)))

You have not followed what I said:

and:

:blush:

2 Likes

thank you again Armin!

I finally got it:

if (column(“mailtyp”) == “A”) join(column(“LowFirstName”),".",column(“LowLastName”),"@",column(“Email_Arr[1]”))
else if (column(“mailtyp”) == “B”) join(column(“LowFirstName”),"_", column(“LowLastName”),"@", column(“Email_Arr[1]”))
else “none”

So we need to learn different Regex syntax for stringmanipulation Node and Column Expression node… :frowning:

Glad to have you in the Forum!

2 Likes

Regex?!

The difference between using the functions in the String Manipulation node and the Column Expressions node is that how we call columns and variables.

Here you can learn more how to use the Column Expressions node:
https://blog.statinfer.com/knime-multitasking-with-column-expressions-node/

:blush:

2 Likes

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