Select to view content in your preferred language

Calculation based on Yes or No values

190
3
4 weeks ago
CMcDonald
Frequent Contributor

Hello,

is it possible in ArcGIS Survey123 web designer to create a calculation based on Yes and No values entered in something like a Single select type question.  The Yes values would have a value of 1 and No values 0.  I would like to add these up and perform a total score. Below is a mock up which hopefully helps.

CMcDonald_0-1727186030894.png

Thankyou

0 Kudos
3 Replies
ChristopherMcClain
Frequent Contributor

I would accomplish this one of two ways

Solution one:

       When creating the choice list for the the questions use the 1 and 0 in the name column but leave the Labels as Yes and No.  So your user will see yes and no as the choices but the form will record  1 or 0.  This is OK if you aren't planning to do anything else with the data in the future.

 

Solution 2:

      If you want to preserve the yes and no values in your table you could put a hidden item below each Question and calculate a value (1 or 0) based on the previous answer.  You would do this by using a the putting an if statement in the calculation field 

Something like if(${PreviousQuestion}='Yes',1,0)

 

With either solution you would then be able to use the calculate field to calculate the total score.

 

 

      

0 Kudos
CMcDonald
Frequent Contributor

Thanks @ChristopherMcClain  I feel Solution 2 would be too time consuming as there are probably over 30 Yes/No questions.

With regards to Solution 1 what type of question are you using that would allow 1 and 0 in the name column but leave the Labels as Yes and No

Thank you

0 Kudos
ChristopherMcClain
Frequent Contributor

The question type would be select_one list.  On the choice tab you can either modify the existing yes no choices by changing the value in the name column to 1 for yes and 0 for no, otherwise you could just create a new entry with the same values (depending if you will have other Yes/No questions in your survey that you don't want to do math with).  The you would add and integer , hidden, or calculate question type to the form and populate the calculation field with the ${fieldname}+${fieldname2}...  .  If this field will be visible to the user you will want to prevent them from overriding the calculated answer.

I have attached a quick example which I have attached