Select to view content in your preferred language

Calculate sum of specific responses in repeat

2575
3
Jump to solution
05-12-2022 06:33 AM
cartezj1
Occasional Contributor

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. 

11-4%
25-24%
325-49%
450-74%
575-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)
0 Kudos
1 Solution

Accepted Solutions
DeonLengton
Esri Contributor

Hi

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

integerexotic_valExotic 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})

DeonLengton_0-1652369822574.png

 

I hope that helps

Regards,

Deon

View solution in original post

3 Replies
DeonLengton
Esri Contributor

Hi

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

integerexotic_valExotic 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})

DeonLengton_0-1652369822574.png

 

I hope that helps

Regards,

Deon

cartezj1
Occasional Contributor

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!

0 Kudos
KristenMeier
Emerging Contributor

Hi, I'm trying to do something similar. I need to collect plant data by lifeform in a plot. I have it set up as a repeat so you enter the species then the canopy cover% and select_one perennial or annual. I want to then calculate the sum of canopy cover for perennial species. I'm having 2 issues: 1)on my shrubs the sum does not give you a total value until you scroll back through the responses, I want it to automatically update. 2) on forbs and graminoids it doesn't sum the canopy values at all. Please help. 

0 Kudos