Skip to main content
Solved

Ignore value of 0 in ExpressionEvaluator


Hi, I'm trying to evaluate if multiple columns in a single row are populated with values and then count how many columns have a value.

For example:

COLACOLBCOLCCOLDCOUNT0000042010276210030001571

I used the ExpressionEvaluator with the following expression:

COUNT = (COLA/COLA)+(COLB/COLB)+(COLC/COLC)+(COLD/COLD)

But obviously dividing by 0 is throwing the whole result off. Is there some form of COUNTIF in FME?

Are you able to suggest a better solution / fix my expression to ignore dividing by zero?

Any help would be greatly appreciated. My brain has decided to give up today...

Best answer by jdh

There is the math operator ? :

(x?y:z) If-then-else. If x is non-zero, then the result is the value of y, and if x evaluates to zero, the result is the value of z.

So something along the lines of (@Value(Cola)?1:0)+(@Value(Colb)?1:0)+(@Value(Colc)?1:0)

You could also look at the ideas from https://knowledge.safe.com/questions/54902/contif-equivalent-function-in-fme.html

View original
Did this help you find an answer to your question?

2 replies

jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • Best Answer
  • March 12, 2018

There is the math operator ? :

(x?y:z) If-then-else. If x is non-zero, then the result is the value of y, and if x evaluates to zero, the result is the value of z.

So something along the lines of (@Value(Cola)?1:0)+(@Value(Colb)?1:0)+(@Value(Colc)?1:0)

You could also look at the ideas from https://knowledge.safe.com/questions/54902/contif-equivalent-function-in-fme.html


  • Author
  • March 12, 2018
jdh wrote:

There is the math operator ? :

(x?y:z) If-then-else. If x is non-zero, then the result is the value of y, and if x evaluates to zero, the result is the value of z.

So something along the lines of (@Value(Cola)?1:0)+(@Value(Colb)?1:0)+(@Value(Colc)?1:0)

You could also look at the ideas from https://knowledge.safe.com/questions/54902/contif-equivalent-function-in-fme.html

Thanks, that's sorted it. I was searching for anything related to expression evaluators and ignoring 0/null values before making this post

 

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings