Question

How to assign a value to a new field when if condition is met

  • 11 September 2021
  • 3 replies
  • 32 views

Badge +1

Using FME Desktop 2021. I have an existing field LicenseNumber with null values and with numeric values. I want to create a new field called License_Values into a table if the following conditions are met:

 

Condition 1

If LicenseNumber is null

Then assign null values to License_Values

 

Condition 2

If LicenseNumber is not null (it has values)

Then assign 123 to License_Values

 

I tried AttributeCreator with a Condition value but it does not work at all. All

it does is assign 123 to every record in the new field called License_Value (Condition 2) and it does not write the null values to License_Value (Condition 1) . My final objective is to have the new field with null values and 123 as long as the conditions are met.

 

image1Condition 

Thank you, much appreciated.


3 replies

Badge +5

I suspect that LicenseNumber is not NULL but one of the other states, Empty or Missing. Put everything through an AttributeFilter and see what ports they come out of.

Badge +1

I suspect that LicenseNumber is not NULL but one of the other states, Empty or Missing. Put everything through an AttributeFilter and see what ports they come out of.

@Gary Nicholson​ Thank you. Yes, I added the AttributeFilter and put everything through (Null, Empty, Missing), I then connected it to an Attribute Creator with all the conditions (Null, Empty, Missing) and it works.

 

Thanks Gazza

Badge +20

Alternatively you can use the Attribute Has a Value clause in the condition to bypass the NULL, EMPTY, MISSING state of the attribute.

Reply