Add constraint comparing another field and NULL

86
5
Jump to solution
05-14-2019 05:14 PM
Highlighted
New Contributor II

Hi, I have two integer fields, "FIELD A" and "FIELD B". I am trying to add a constraint on "Field A"  that meets the following conditions:

If "Field B" IS NULL, "Field A" can be any value (including NULL)

If "Field B" IS NOT NULL, "Field A" must be greater than "Field B"

Can anyone assist with the syntax please?

Regards, Damian

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Frequent Contributor II

You just want it to eval to true so just give it a 1.

if(string-length(${Field_B}) > 0,${Field_A} > ${Field_B},1)

View solution in original post

Reply
0 Kudos
5 Replies
Highlighted
Frequent Contributor II

In 123 Null is empty string.  So compare to '' or "".

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Adding on to Doug's comment, use the function string-length(${q}) > 0 to test for null - all question types evaluate to a string length of 0 when null.

Reply
0 Kudos
Highlighted
New Contributor II

Thank you gents, however the answer still alludes me. The closest I can come up with is the following:

if(string-length(${Field_B}) > 0,${Field_A} > ${Field_B},*** any number or NULL ***)

Any further assistance would be greatly appreciated.

Reply
0 Kudos
Highlighted
Frequent Contributor II

You just want it to eval to true so just give it a 1.

if(string-length(${Field_B}) > 0,${Field_A} > ${Field_B},1)

View solution in original post

Reply
0 Kudos
Highlighted
New Contributor II

Ahh, many thanks Doug.

Reply
0 Kudos