3

i stumbled across the following challenge in FME:

how to deal with NULL values if you want to perform a calculation for a new attribute. For example, I want to sum up values (could be any other kind of arithmetics).

The expected result is fine as long as no NULL Value is involved. FME turns any calculation into a NULL result if any NULL is involved (see documentation).

Result using a numeric expression ---------------------- Result using a non-numeric expression to illustrate
enter image description here enter image description here

The question that haunts me is, how to treat those NULL values as 0 in the calculation without changing the value to an actual 0 (as the NullAttributeMapper would).

The result I am looking for is the following:

If all values are NULL i want the result to be NULL, otherwise I want the NULL value to be treated as 0. Furthermore, I dont want the NULL values to be changed to 0, so I can distinguish between NULL and 0 in further calculations.

1 Answer 1

4

The AttributeManager has a functionality to handle NULL as 0 (or any other value you like), without tampering with the orignal values.

res0

The result is what i was looking for:

Result using a numeric expression in combination with a condition to preserve NULL
res2
Result using a non-numeric expression to illustrate
res1
1
  • 1
    Yes, that's the best way. Another way would be to use a NullAttributeMapper transformer first, assuming you're OK with replacing the values permanently. Dec 21, 2022 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.