I've created a survey for address collection and was wanting to create a multi-conditional instance_name. Within the addresses, some could have a prefix or a suffix with the road. I've created a select_one field that allows the user to determine if a prefix or suffix exists.
I want to do something like if prefix exists and suffix exists print 123 E Main W St, else if prefix exist and suffix doesn't exist print 123 E Main St, else if prefix doesn't exist and suffix does exist print 123 Main W St, else if prefix doesn't exist and suffix doesn't exist print 123 Main St.
What's the best way to create something like above for the instance_name?
Solved! Go to Solution.
Hi @michael_vetter,
Have you tried using a if() statement or nested if() statement? Are you able to provide a copy of your xlsxform and the questions/fields you want to pull the information from for the instance name. We can take a look and then let you know if what you are trying to achieve is possible.
Regards,
Phil.
Hi @michael_vetter,
Have you tried using a if() statement or nested if() statement? Are you able to provide a copy of your xlsxform and the questions/fields you want to pull the information from for the instance name. We can take a look and then let you know if what you are trying to achieve is possible.
Regards,
Phil.
Hi Phil,
I was going to use a nested if() statement, but wasn't sure if there was a better way to achieve what I wanted.
So below is what I ended up creating and it appears to be what I wanted.
if(selected(${Fraction_Present},'Yes') and selected(${Prefix_Present},'Yes') and selected(${Suffix_Present},'Yes'), concat(${STREET_NUM}+" "+${FRACTION}+" "+${PREFIX}+" "+${STREET_NAME}+" "+${SUFFIX}+" "+${STREET_TYPE}),if(selected(${Fraction_Present},'No') and selected(${Prefix_Present},'Yes') and selected(${Suffix_Present},'Yes'), concat(${STREET_NUM}+" "+${PREFIX}+" "+${STREET_NAME}+" "+${SUFFIX}+" "+${STREET_TYPE}),if(selected(${Fraction_Present},'No') and selected(${Prefix_Present},'No') and selected(${Suffix_Present},'Yes'), concat(${STREET_NUM}+" "+${STREET_NAME}+" "+${SUFFIX}+" "+${STREET_TYPE}),concat(${STREET_NUM}+" "+${STREET_NAME}+" "+${STREET_TYPE}))))
Thanks for the help!
Hi @michael_vetter,
That looks great, well done. Without seeing your xlsform and further understanding the workflow, it looks like the nested if() statement you are using is correct and should work as expected. There is really no better way to achieve what you want, and if this works and displays the correct instance name in all cases, I would use it as is.
Regards,
Phil.