Survey123 Multiple conditional calculations

311
1
Jump to solution
04-08-2019 07:29 AM
Highlighted
Occasional Contributor III

How can I write a calculation to default to one of the following? basically if the phone number option 1 is null then check the second option and so on until one of the following displays a phone number.

${NEOFormPHONENUMBER}
${NEOFormMOBILENUMBER}
${NEOFormBUSINESSNUMBER}
${NEOFormEMERGENCYCONTACTNAME}
${NEOFormEMERGENCYNUMBER}

Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Occasional Contributor II

You can check for nulls using the string-length function or by checking a value against an empty string. If you nest some "if" statements, the calculation will return once a condition is met.

if(string-length(${NEOFormPHONENUMBER}) != 0, ${NEOFormPHONENUMBER}, if(string-length(${NEOFormMOBILENUMBER}) != 0, ${NEOFormMOBILENUMBER}, if(string-length(${NEOFormBUSINESSNUMBER}) != 0, ${NEOFormBUSINESSNUMBER}, if(string-length(${NEOFormEMERGENCYNUMBER}) != 0, ${NEOFormEMERGENCYNUMBER}, "NONE"))))

if(${NEOFormPHONENUMBER} != "", ${NEOFormPHONENUMBER}, if(${NEOFormMOBILENUMBER} != "", ${NEOFormMOBILENUMBER}, if(${NEOFormBUSINESSNUMBER} != "", ${NEOFormBUSINESSNUMBER}, if(${NEOFormEMERGENCYNUMBER} != "", ${NEOFormEMERGENCYNUMBER}, "NONE"))))

Documentation: Formulas—Survey123 for ArcGIS

View solution in original post

1 Reply
Highlighted
Occasional Contributor II

You can check for nulls using the string-length function or by checking a value against an empty string. If you nest some "if" statements, the calculation will return once a condition is met.

if(string-length(${NEOFormPHONENUMBER}) != 0, ${NEOFormPHONENUMBER}, if(string-length(${NEOFormMOBILENUMBER}) != 0, ${NEOFormMOBILENUMBER}, if(string-length(${NEOFormBUSINESSNUMBER}) != 0, ${NEOFormBUSINESSNUMBER}, if(string-length(${NEOFormEMERGENCYNUMBER}) != 0, ${NEOFormEMERGENCYNUMBER}, "NONE"))))

if(${NEOFormPHONENUMBER} != "", ${NEOFormPHONENUMBER}, if(${NEOFormMOBILENUMBER} != "", ${NEOFormMOBILENUMBER}, if(${NEOFormBUSINESSNUMBER} != "", ${NEOFormBUSINESSNUMBER}, if(${NEOFormEMERGENCYNUMBER} != "", ${NEOFormEMERGENCYNUMBER}, "NONE"))))

Documentation: Formulas—Survey123 for ArcGIS

View solution in original post