calculating multiple select_one field values

01-29-2020 06:38 AM
New Contributor

I'm new to this, so bear with me.  I am trying to come up with a total score for six "select_one" type fields.  In my choices tab I have given the various responses a unique number (1-10) in the name field.  In my calculation field (survey tab) I multiply these times 1.667 to put it on a 100 scale then subtract the number from 100 to give a final score.  That's what I want to do.  Not working.  This is the calculation I used: 

100 - ((${surrounding_area} +  ${throat} +  ${grate} +  ${lid} +  ${wall} + ${invert}) * 1.667)

What I am seeing is the in the calculation of the values (e.g.,) 5 + 8 + 0 + 4 + 0 + 6 = 580406, not 21.

Tags (1)
0 Kudos
3 Replies
MVP Notable Contributor

Set the bind:type column to int (or a float if needed).  All fields act like strings by default in 123 so the + is a concatenate.

If you need more info search the forum there are several posts on it.

Hope that helps.

0 Kudos
Esri Contributor

Hi David,

In addition to Doug's comment, an alternative would be using 'number(${question})' to convert the string to numeric value. And you don't need to set the bind:type column to int, just leave it as it is.

So something like this: number(${surrounding_area}) + number(${throat}) + number(${grate}) ... 

I was using the method (setting bind:type column to int) before and found that if the question is an optional question and user did not answer the question, it will return an empty value (NaN). The following calculation would fail if there's an empty value (NaN) in the calculation. 


However, if the question type hasn't been set to int or decimal (i.e. leave it as it is), the empty value that it will return is an empty string. number(${question}) will read the empty string as 0 so it will have no impact on the calculation. 

Please see the 'Empty values' section for more information: Formulas—Survey123 for ArcGIS | Documentation  

My recommendation is, if there's no optional question, use Doug's method, otherwise you can consider using the method I described. 



0 Kudos
New Contributor

Thanks. I used the number function and it worked like a charm.