Skip to main content

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...

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


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

 

 


Reply