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

968
10
03-20-2023 08:41 AM
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})

1 Solution

Accepted Solutions
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

10 Replies
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

New Contributor II

That did the trick, thanks Doug!

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}...

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.

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

MVP Esteemed Contributor

Are those 3 fields set to bind int?

New Contributor II

I believe so, yes

MVP Esteemed Contributor

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

New Contributor II

Good call, see attached, thanks