Select to view content in your preferred language

Tally points in a Survey123 questionare.

677
8
09-05-2023 12:45 PM
BobNoyes
Occasional Contributor

I have a survey with 16 questions. Each question is the Singel Select type with 2 or 3 answers. Each answer is given a score of either 0, 5, 10, or 15 points. What I want to do is set it up so that the points are added up and automatically populate a Home Assessment Score field with the sum of the points (somewhere between 0 and 130 points). I also want it to automatically select the Home Assessment Rating field rating (0-25 = Low Risk Hazard, 26-50 = Medium Risk, 51-100 = High Risk, and > 100 = Extreme Risk. 

Any suggestions would be appreciated, thanks!

Link to Survey here.

Question example:

BobNoyes_0-1693942892535.png

 

0 Kudos
8 Replies
jcarlson
MVP Esteemed Contributor

What is the value being stored when those options are selected? Is it storing the actual numeric value for the score?

It would be tedious to write out, but would be as simple as $question_1 + $question_2 + $question_3 in the calculation column of your assessment score field.

If the questions have some value other than the numeric score, you'd need your expression to decode the values first, then add them up, which is likely to be even more tedious.

Personally, I'd suggest using a custom JavaScript function to handle this, as that can be much easier to work with and debug than a long calculation expression.

- Josh Carlson
Kendall County GIS
BobNoyes
Occasional Contributor

At this point (I built this via the Survey123 web tool) the value being stored is the answer selected. See the example I posted the screenshot of. I am not that familiar with customization of the table via Survey123 Connect. Like, is there a way to associate the needed points for each possible response and then create a script like you suggest selecting the number selected?

I am wondering if another way of approaching this would be set up a numerical answer to the question rather than radio buttons to select the answer? 

0 Kudos
jcarlson
MVP Esteemed Contributor

Switching to numeric values would be much simpler. But to answer your question, it would be simple enough to have an object in JS in which the answer and its point value act as a key/value pair.

var q_points = {
  "First Answer":  5,
  "Second Answer": 10,
  "Third Answer":  0,
  "First Answer but to a different question": 5,
  "and so on": 10
}

And then you could use the value of the question to pull the points. Assuming you included your answers on the JS function as parameters like "q1", "q2", etc, it might look like this:

var the_sum = q_points[q1] + q_points[q2] + ...

return the_sum
- Josh Carlson
Kendall County GIS
BobNoyes
Occasional Contributor

Interesting. I will play around with this and see what happens. There is a bit of a learning curve happening here as I have never worked on the spreadsheet side of things via Survey Connect. Thanks for the suggestions. 

0 Kudos
JenniferAcunto
Esri Regular Contributor

Just an FYI JS is not supported for public surveys so if you plan on making your survey accessible to everyone you will need to do your calculations in the calculation column of your survey.

- Jen
BobNoyes
Occasional Contributor

Ah, good to know. I knew there was a reason why I have always avoided building surveys via Survey123 connect.....

0 Kudos
JenniferAcunto
Esri Regular Contributor

Connect works with all surveys, it is specifically using a JavaScript function that doesn't work in public surveys.

- Jen
BobNoyes
Occasional Contributor

Thanks Jennifer, that is what I thought you meant. 

0 Kudos