Columns expression vs Expression node

Recently I updated my knime version and I cannot use anymore the column expression node, because of this, I am replacing the information in that nodes for new expression in the EXPRESSION node:
But for some cases, I cannot use it, because it doesn’t has the functions I used before)

example I want to do this:

if (isMissing($[“ID Number”])) { MISSING }

else { join(left($[“ID Number”], 6), “/”, right($[“ID Number”], 4)) }

but there is no alternative in EXPRESSION node to check if the value in a column is missing, or to use the left and right functions as I used in column expression node- so now is very difficult to find how to do this

Is someone facing this too?

Update: I found this option for the second part:

join(“/”,first_chars($[“ID Number”],6),last_chars($[“ID Number”],4))
any idea on how to get a result if a value in a column is missing?

Example

=if(isMissing(${“ID Number”], “check”, “ok”)

Hello @Mariaper

Could you please try the following expression for “Expression” node:

if($[“ID Number”] = MISSING, “MISSING”, join(“”, first_chars($[“ID Number”], 6), “/”, last_chars($[“ID Number”], 4)))

This works fine for me.

3 Likes

Hi,

you can simplify even further by using “+” for concatenating/joining strings:

if($[“ID Number”] = MISSING,
MISSING,
first_chars($[“ID Number”], 6) + “/” + last_chars($[“ID Number”], 4))

2 Likes

Happy KNIMEing @Mariaper

1 Like

I have another question in same node- is it possibl to add something like:

if(and(columnA=2, not(columnB=2), “ok”,”check”

I am trying and it seems it doesn’t recognize the and, maybe concatenating the ifS?

function1 and function2

is the syntax (usual issue with programming languages that you have to deal with a mixture of functions and operators, some stuff is and(), some is and and some use .and() or similar

Then, the expression in Expression node would be

if($[“columnA”]=2 and not$[“columnB”]=2, “ok”, “check”)

Works for me :grinning_face:

PS. In case of new queries, please create new topic. That is easier to follow for other KNIMErs

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