Select to view content in your preferred language

Reference a select_one answer that occurs within a repeat outside of the repeat

234
6
04-25-2025 10:52 AM
Jonatanson_DUC
Emerging Contributor

Hi everyone!

I'm creating a ground cover identification form that contains two repeats.

The first requires the surveyor to select different ground cover types (vegetation, bare ground, water, etc.) then input their percent cover of a 1m by 1m plot.  At the end of this repeat is a box which sums the entered percentages in real time so the surveyor knows when they've reached 100%.  I've also inserted a group with two notes to display each ground cover type and percentage so the user knows what they've entered so far.

The second repeat is functioning similarly, except instead of needing to reach 100%, it needs to reach the percentage entered for the vegetation ground cover type from the repeat above.

I'm pretty lost on how to accomplish this or if it's even possible.  Does anyone have experience referencing repeat answers outside of a repeat?  Any help is appreciated!

0 Kudos
6 Replies
Neal-Kittelson
Frequent Contributor

Your box summing the percentage is outside the repeat correct?  If so, there are aggregation functions for repeats to accomplish what you are trying to do:

https://community.esri.com/t5/arcgis-survey123-blog/survey123-tricks-of-the-trade-repeats/ba-p/89804...

Your second repeat will probably require some hidden calculation fields inside the repeat to summarize the individual ground cover type with some if statements to filter your sums

inside the repeat: type: hidden name: bareground      calculation:if(selected(${type},"bare ground"),${percent},"")   bind:: int

outside the repeat:    type: note  calculation: sum(${bareground})

 

0 Kudos
Jonatanson_DUC
Emerging Contributor

Thanks for this!  Entering this formula in the calculation field (if(selected(${cover_type},"vegetation"),${cover_percentage},"") mostly works, but I'm running into an issue when there are more cover type entries than vegetation.

If I enter vegetation = 70% and do not enter anything else, the "vegetation" field populates perfectly.
If I enter vegetation = 70%; bare ground = 30%, the "vegetation" field shows up blank.

Any ideas?  I'm assuming it's because there's an additional entry that isn't "vegetation", so it doesn't return return the percentage, but a blank ("").

0 Kudos
j-bromp
Frequent Contributor

Can you explain a bit more what the second repeat does? the first repeat is for showing different vegetation makeup of a 1m² area. So in the second repeat are you saying that if the first repeat only has 70% vegetation cover, the second repeat needs to equal 70%?

Or is it more like you want to break down the first repeat into specific types showing their individual percentage coverage?

Bit lost sorry but keen to help you.

0 Kudos
Jonatanson_DUC
Emerging Contributor

Hey!  Absolutely.

The second repeat is to break down the vegetation types.  So, for example, the vegetation makes up 70% of the 1m² area; the second repeat then describes what types of vegetation equal up to that 70% coverage.

Repeat One:
Vegetation = 70%
Bare ground = 20%
Water = 10%

Repeat Two:
Grass = 40%
Willows = 20%
Moss = 10%

0 Kudos
Jonatanson_DUC
Emerging Contributor

Sure thing!  Your assumptions are correct, though.  Right now I'm trying to call the vegetation percentage from repeat one to use for reference in repeat two, but if it would be in my best interest to break down the ground cover types to accomplish what I'm looking for, I'd be down for that.

The first repeat is to summarize ground cover up to 100% (one of these being "vegetation").

The second repeat is to summarize the vegetation types within the ground cover = vegetation, which should equal up to the percentage entered in the first repeat.

So for example...

Repeat One:
Vegetation = 70%
Bare ground = 20%
Water = 10%

Repeat Two:
Moss = 20%
Grass = 40%
Willow = 10%

0 Kudos
j-bromp
Frequent Contributor

@Jonatanson_DUC  Ok I think I'm with you. When you say second repeat I am taking it to mean a whole other repeat group, going with this, my first recommendation would be to do away with the second repeat and calculate the vegetation % make up (which is currently handled by the second repeat), from within the first repeat. Unless you specifically need the second repeat for some reason, this is a much easier approach. Given that you are asking though, I assume you really want the second repeat. 

You can't index another repeat from within a repeat, that's just a limitation, so you're going to need to build your indexed-repeats, outside of the second repeat, and then refence back to it.

Again, you will save yourself a lot of lines and calculations if you just combine the two repeats into one. but it is possible (albeit not especially dynamic) to do it with two repeats. Do the screenshots below look something like what you are trying to achieve? (comments change, showed two repeats)

jbromp_0-1745979552419.png 

jbromp_2-1745979655202.png

 

jbromp_3-1745979678589.png

 

Overall for what it sounds like you are trying to achieve, I would do a single repeat, have your ground cover questions, be realistic about how many different ground cover types the area is likely to be split into (doesn't have to cover infinite options), lets say 20 options for ground cover types (seems like a lot to me but idk). Have each question visible only if the previous one is answered. That way the survey isn't busy for the user. Then after that section (you can group that section if you like), have another group. This new group will be your vegetation make-up. Again, have 20 odd questions(?), asking for the type of vegetation and the percentage of the area they make up). then have your running total below that, and your comment about sufficient coverage or not. Having repeats trying to reference each other gets very long with the calcs.

Hopefully that helps, or maybe i've completely misunderstood.

0 Kudos