Calculations based on yes_no response

45
4
02-01-2019 07:50 AM
Highlighted
New Contributor

#yes-no

I need to make some calculations based on yes_no responses.  The questions are inside a set of repeats where the user gathers plant data from multiple plants along multiple transects.  At the end, for all plants selected 'yes', I need the total number of plants recorded and the total number of "bites" on those plants.  The following statement generates an error stating 'if' requires 3 arguments and only 2 provided.  

if(selected(${yes_no},'yes'),sum(${countbites}))

Once I get this figured out, I will do the same with the number of plants recorded 'yes' and divide the numbers.  I'm sure there is a long calculation that can do this all at once, but for now, this will do.

Tags (1)
Reply
0 Kudos
4 Replies
Highlighted
New Contributor III

You need 3 arguments in an if statement. ie. If I goto the store, I will have milk, if not, I will not have milk. With the three bolded things being the three arguments. 

if(selected(${yes_no},'yes'),sum(${countbites}),[enter what will happen if no is selected])  

if you don't want anything to happen, then it would look like this...

if(selected(${yes_no},'yes'),sum(${countbites}),"")  

Highlighted
New Contributor

That syntax still gives me the total # of bites, including 'no' responses.  Do I need another statement at the end where you have ""?    I need to do this for both yes and no answers but I need to do it separately.

Reply
0 Kudos
Highlighted
New Contributor

After entering some data, I notice the total bites only appears when I choose a species and then select yes.  If I select no, nothing is displayed. 

Ex.  Species 1 - 'no' - 3 bites =  nothing displayed

Species 2 - 'yes' - 0 bites = 3 displayed

Species 3 - 'yes' - 4 bites = 7 displayed

Species 4 - 'no' = 5 bites = nothing displayed

Trying to learn this on my own with nothing more than GeoNet and the website.

Reply
0 Kudos
Highlighted
Esri Esteemed Contributor

Hi Jimmy,

This is best done by having the calculation in the repeat section and then summing at the end.   I've attached a sample that does something similar - count the number fo children in the repeat section.  You do the number calculation in the repeat section based on yes/no, and then sum at the end.

Reply
0 Kudos