Subtraction with missing value in column expression node should lead to missing (result) value

Hi Knime-Community,

the following problem: In the column expressions node I have performed a calculation (x-y)/x.
If y has a missing value, I get the value 1, as if y was counted as 0. But if y has a missing value, I would like to have a missing value in my result column.
I now see two possibilities:

  1. Either tell the formula to only calculate if y is not a missing value,
  2. or formulate an if-condition in a sequence node, so that if there is a 1 in the rows of the result column, it should make a missing value out of it.

However, I can’t get either of these to work. Does anyone have an idea for one of the two approaches? Or a completely different suggestion for a solution?
This would be great :slight_smile:.

Thanks a lot
Christian

1 Like

I’d start with trying the following expression in the Column Expressions node:

if(isMissing(column("y")))
{ missingValue() }
else
{ (column("x")-column("y"))/column("x") }
4 Likes

Hello @Christian_Essen,

Column Expressions node is based on JavaScript. See here on JS handling of null (and undefined) values:

(Internal Reference: AP-14016)

Br,
Ivan

@elsamuel: Thank you very much, it worked great :upside_down_face:.
Christian

1 Like

@ipazin: Thank you very much for the additional explanation :slight_smile:.
Christian

1 Like

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