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}
Solved! Go to Solution.
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
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