Counting repeat select_multiple answers

994
4
06-01-2020 11:42 PM
NedMay
by
New Contributor

Hello, 

I am trying to set up a species list for our botany team in Survey123 using an xlsform. I have set up a searchable species list and then a select-multiple list of lifeform types. The botanist will select a species, and then one, multiple or no lifeform. I want to be able to add how many times each lifeform was selected. 

For example: botanist chooses a species - xx

Then chooses a lifeform - LS and SS

Then chooses another species - xx

And chooses a lifeform - PG

Display - LS used 1, SS used 1, PG used 1, etc.

For each of the select-multiple options, I want to be able to sum the number of times it was selected. It currently works if only selecting one lifeform per species but fails with more.

Thank you!! 

0 Kudos
4 Replies
DougBrowning
MVP Esteemed Contributor

Is your sum() outside of the repeat?

0 Kudos
NedMay
by
New Contributor

I've updated the response with the survey, the sum is outside the repeats and seems to work with only one lifeform selected. I think the if(${lifeform} = 'XX', 1, 0) does not work with select_multiple?

0 Kudos
DougBrowning
MVP Esteemed Contributor

With select multiple you have to use jr:choice-name(choice, 'question').  If you have species1;species2 then = will not be true.  See the formulas page for more info Formulas—Survey123 for ArcGIS | Documentation 

For my forms when doing a species list I use a repeat.  Much better database structure to have one species per record vs a ; separated list.  Hard to do analysis on that.  Our legacy program does this and we ended up separating them out.  It also allows me to check for dups, and have unknown codes all built in.  I have posted this before if you need it.

Hope that helps

0 Kudos
Emily1
by
New Contributor

I have a related question. I have a survey that requires the user to list off all species present and give the cover for each. That's all in a repeat. I would like to show the user what species were selected in the set of repeats, but can I generate a list of species names outside the repeat that shows the label, not the name? My species list has a code for the name and the label spells out the Genus/species and I'd like to show the label, preferably with spaces between names so the user can check that they have entered data for every species present.

0 Kudos