Calculate sum of specific responses in repeat

359
2
05-12-2022 06:33 AM
by
New Contributor III

I'm trying to calculate the sum of certain responses in a repeat. I am able to successfully sum all the responses in a repeat thanks to this post. But I have not figured out how to sum certain responses from a repeat.

This specific group of repeats is for invasive species, and the percent coverage is displayed as a category. The data collection method preceded my arrival so I cannot change anything as it is a long term dataset. So behind the scenes the percentage category is really an integer. See below.

The data analysis part calculates the sum of coverage for 4 invasive species out of the many. So a coverage of 1-4% of Eleagnus, and 25-49% of Microstigeum would sum to 4. I've arranged the four species of interest at the top of the list because these are chosen the most.

 1 1-4% 2 5-24% 3 25-49% 4 50-74% 5 75-100%

I've tried selected() but being boolean it doesn't help. I've looked into index repeats, but it doesn't seem to fit either. According to my pomodoro tracker I've spent 17.5 hrs trying to search for what I'm trying to do if it's possible. I've attached abridged CSV for the survey and an abridged exotic species list. The latter includes the top four choices and a few non-choices for the sum.  The survey CSV shows in orange what I was last using.

Side note: If anyone is curious about the table formatting using join and concat to view as a table the responses in repeats below a repeat see here. It's great for viewing for vegetation surveys using select_one in the repeat.

Tags (3)
1 Solution

Accepted Solutions
Esri Contributor

Hi

I added an integer field (you can use a calculated field) inside the repeat:

 integer exotic_val Exotic Value

The calculation of this field check for exotic species being entered and use the category value if it is an exotic species. If it isn't an exotic species it assigns the value 0:

if(selected(\${Exotic_Sp}, 'Elaeagnus_pungens') or selected(\${Exotic_Sp}, 'Microstegium vimineum'),\${Exotic_Sp_Lvl},0)

It uses the basic if syntax:

 if(condition, a, b) If the condition evaluates to true, returns a; otherwise, returns b.

Then just change your sum_Exotics3 calculation to: sum(\${exotic_val})

I hope that helps

Regards,

Deon

2 Replies
Esri Contributor

Hi

I added an integer field (you can use a calculated field) inside the repeat:

 integer exotic_val Exotic Value

The calculation of this field check for exotic species being entered and use the category value if it is an exotic species. If it isn't an exotic species it assigns the value 0:

if(selected(\${Exotic_Sp}, 'Elaeagnus_pungens') or selected(\${Exotic_Sp}, 'Microstegium vimineum'),\${Exotic_Sp_Lvl},0)

It uses the basic if syntax:

 if(condition, a, b) If the condition evaluates to true, returns a; otherwise, returns b.

Then just change your sum_Exotics3 calculation to: sum(\${exotic_val})

I hope that helps

Regards,

Deon

by
New Contributor III

Thank you so much! I took some extra steps to make the if(selected) to be hidden, and the sum as read only to avoid accidental changes. I really appreciate your help!