Add constraint comparing another field and NULL

965
5
Jump to solution
05-14-2019 05:14 PM
DamianMilne
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

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

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

0 Kudos
5 Replies
DougBrowning
MVP Esteemed Contributor

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

0 Kudos
JamesTedrick
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.

0 Kudos
DamianMilne
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.

0 Kudos
DougBrowning
MVP Esteemed Contributor

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)

0 Kudos
DamianMilne
New Contributor II

Ahh, many thanks Doug.

0 Kudos