Select to view content in your preferred language

Assign score based on Select one question type, can only score 2 of three answers

1076
10
Jump to solution
03-20-2023 08:41 AM
DanielChelist
New Contributor II

We are trying to create a survey in Survey123 Connect where a score is assigned based on user choice for a select_one type question in an integer type following the question. The issue we are having is that we are only to generate scores for 2 of the questions depending on the calculation formatting. See screenshots below as well as the calculation used in the integer type. Any suggestions would be greatly appreciated 

if(${a2o_1}="yes",${c2},${c1}) or if(${a2o_1}="yhi",${c3},${c1}) or if(${a2o_1}='no',${c1},${c1})

Survey123 Question.JPG

Survey123 Question pt2.JPG

Survey123 Question pt3.JPG

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

You cannot use or inbetween if statements like that.  You need to use the else in the if.  Looking at your options I think this would work and be simpler.

if(${a2o_1}="yes",${c2}, if(${a2o_1}="yhi", ${c3}, ${c1}))

This assumes it will never be blank.

Hope that helps

View solution in original post

0 Kudos
10 Replies
DougBrowning
MVP Esteemed Contributor

You cannot use or inbetween if statements like that.  You need to use the else in the if.  Looking at your options I think this would work and be simpler.

if(${a2o_1}="yes",${c2}, if(${a2o_1}="yhi", ${c3}, ${c1}))

This assumes it will never be blank.

Hope that helps

0 Kudos
DanielChelist
New Contributor II

That did the trick, thanks Doug!

0 Kudos
DanielChelist
New Contributor II

so, if I wanted to sum the results from multiple questions, what would be the proper syntax for that?

ex

${a2o_1}+${a2o_2}...

0 Kudos
DougBrowning
MVP Esteemed Contributor

Yes typically that is what I do.  One line for each sum then one master that sums them all up.  Set the bind type field to int so you get a number and not a string.  Can also set the temp fields bind esri type to null and they will stay out of the feature service.

0 Kudos
DanielChelist
New Contributor II

hmm, I must be doing something wrong. Getting an empty output with the following. Same empty output with parenthesis around the calculation

Survey123 Question pt4.JPG

0 Kudos
DougBrowning
MVP Esteemed Contributor

Are those 3 fields set to bind int?  

0 Kudos
DanielChelist
New Contributor II

I believe so, yes 

Survey123 Question pt5.JPG

0 Kudos
DougBrowning
MVP Esteemed Contributor

Yes that looks right.  At this point just post the form or just guessing.  

0 Kudos
DanielChelist
New Contributor II

Good call, see attached, thanks

0 Kudos