Math Formula node's if(x,y,z) function not outputting value for every record

I have a Math Formula node in Knime 3.5.3 which is not always outputting a value for every record. The expression in the node is below, and uses an if(x,y,z) function to check two Boolean field values before comparing some Double values, then outputting a true or false condition value.

if($Has_Actual$ && $Has_Prediction$ &&
($Count*(Investment)$>2 &&
abs($Investment$-$Predicted_Investment$)>2*$Standard deviation(Investment)$)
|| ($Count*(Investment)$<=2 &&

But in the node output, only rows that have “true” values for the two Boolean fields ($Has_Actual$ and $Has_Prediction$) are getting values output. My expectation is that the if(x,y,z) function should have an output for every row. Since a “false” value for either one of my Boolean fields will result in the test condition not being true, I am expecting the output to be the false condition value (0 in my expression).

Note, if $Has_Actual$ is false, then $Investment$ is missing, and $Count*(Investment)$ and $Standard deviation(Investment)$ might be missing. If $Has_Prediction$ is false, then $Predicted_Investment$ is missing. Perhaps the Math formula is not short-circuiting on each && clause and tries to process the later expressions, which would cause NaN or nullpointer exceptions?

Why might this function not be outputting values?


I’m guessing there might be a problem with missing values. Try “Missing Value” node and replace all missing numeric values with zero. Then apply Math Formula node, there should not be any row with missing output.

Martin K.

Indeed, I have confirmed that ensuring that all fields in the expression have a value results in every row getting an output value. Perhaps changing this behavior could be a feature request? I would love to have the conditional operators short-circuit as they do in Java. Thanks!