Select to view content in your preferred language

Survey123 Connect if/concat

834
3
Jump to solution
04-18-2023 06:17 AM
DionysiosKerasidis1
Emerging Contributor

Hi everyone 

I am relatively new in survey123 and i am struggling to achieve something if anyone can help.

The concept is very simple.

 

Based on the answer above i want the ID to start with either TP-(numbers)   or BM-(numbers) depending what the feature is. Alphanumerical ID

 

 

DionysiosKerasidis1_0-1681823700448.png

 

i am using this calculation but no luck for sometime now.

if(selected(${Feature_Type}, 'Trial Pit', concat('TP', '-', ${Feature_Type}))), concat('BM', '-', ${Feature_Type})

i would really appreciate any help.

 

Thank you

 

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Your parentheses are off and you are using selected a bit off.

You can do selected(question, value) or question = value but you have them intermixed.

if(selected(${Feature_Type}, "Trial Pit"), concat('TP', '-', ${Feature_Type}), concat('BM', '-', ${Feature_Type}))

or

if(${Feature_Type} = "Trial Pit", concat('TP', '-', ${Feature_Type}), concat('BM', '-', ${Feature_Type}))

Note this will give you BM- even when the field is empty.  If you want it to stay blank until they pick something you can do.

if(selected(${Feature_Type}, "Trial Pit"), concat('TP', '-', ${Feature_Type}), if(selected(${Feature_Type}, "Bellmouth"), concat('BM', '-', ${Feature_Type}), "")

Hope that helps

View solution in original post

3 Replies
JeffSilberberg
Frequent Contributor

 

I am struggling with any number of issues as well,  but in this one I thin it might be an out of place coma. 

if(selected(${Feature_Type} = "Trial Pit", concat('TP', '-', ${Feature_Type}))), concat('BM', '-', ${Feature_Type})

for if (condition, TRUE, FALSE)

https://community.esri.com/t5/arcgis-survey123-questions/conditional-if-then-else-logic-in-survey123...

 

0 Kudos
DougBrowning
MVP Esteemed Contributor

Your parentheses are off and you are using selected a bit off.

You can do selected(question, value) or question = value but you have them intermixed.

if(selected(${Feature_Type}, "Trial Pit"), concat('TP', '-', ${Feature_Type}), concat('BM', '-', ${Feature_Type}))

or

if(${Feature_Type} = "Trial Pit", concat('TP', '-', ${Feature_Type}), concat('BM', '-', ${Feature_Type}))

Note this will give you BM- even when the field is empty.  If you want it to stay blank until they pick something you can do.

if(selected(${Feature_Type}, "Trial Pit"), concat('TP', '-', ${Feature_Type}), if(selected(${Feature_Type}, "Bellmouth"), concat('BM', '-', ${Feature_Type}), "")

Hope that helps

DionysiosKerasidis1
Emerging Contributor

thank you so much Doug, i slightly amended your formula and it did do what i needed.

 

i really appreciate your time to help.