Skip to main content
Solved

Ignore value of 0 in ExpressionEvaluator

  • March 12, 2018
  • 2 replies
  • 66 views

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

2 replies

jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • 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
  • 19 replies
  • 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

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