I have built a survey with fifteen different " select_one" questions with the answers being either yes, no, or N/A. I want to add a new field to my survey that sums the number of 'no' answers from the 15 questions. Is this possible and can you show any examples?
thank you,
Brendan
There might be a more elegant solution to this, but this will work: start by adding 15 more questions, all hidden and null. Each of those hidden questions will have a calculation like if(selected(${Q1}, 'no'), '1', '0'). Then you have one more field that adds each of those together.
Note that hidden types are treated as text, so you should use the int() function to treat their values as numbers in the calculation!
type | name | calculation | bind::esri:fieldType |
---|---|---|---|
select_one yes_no | Q1 | ||
hidden | Q1Boolean | if(selected(${Q1}, 'no'), '1', '0') | null |
select_one yes_no | Q2 | ||
hidden | Q2Boolean | if(selected(${Q2}, 'no'), '1', '0') | null |
select_one yes_no | Q3 | ||
hidden | Q3Boolean | if(selected(${Q3}, 'no'), '1', '0') | null |
select_one yes_no | Q4 | ||
hidden | Q4Boolean | if(selected(${Q4}, 'no'), '1', '0') | null |
text | TotalNo | int(${Q1Boolean}) + int(${Q2Boolean}) + int(${Q3Boolean}) + int(${Q4Boolean}) |
I did something similar as Nick, except my question type was calculation and I set the esri:fieldType to null because I didn't want a field in the schema. That's not your scenario, but if you ever want to do that, it comes in really handy.
Thank you Nick and Shana! Really appreciate the help.
You bet! I had a lot of calculations in my Survey that I didn't want fields for, so when a release made that possible I was pretty stoked. If you don't put null in the fieldType it will create a field for you, so you could still use a calculation question type (instead of text) if you wanted to.