I am building a survey that my technicians use to evaluate the compliance status of telecom towers. During the course of a tower inspection, a technician may encounter a multitude of deficiencies in a number of categories, such as the foundation, the base plates, structural members, wire tensions, finish, and so on. I use repeats of varying complexity to manage each particular category, but one common feature to all is an assessment of the asset's condition. Two of the responses for asset condition are "hazardous" and "poor". I would like to implement a counter for all instances of either of these choices across all repeats (and all records in every repeat), so that when the technician completes the survey, I can ensure that the number of deficiencies reported in the survey is at least the same as the number of things reported to be in poor or hazardous condition, by setting the number of repeats in that section to the counter.
I have tried multiple methods to implement this, including messy if(selected()) statements, count(selected()) statements, sum statements, and the like. I've consulted a number of posts on this forum regarding this topic, but nothing I have come across seems to do quite what I need. The closest I have gotten so far results in 'hazardous' being counted twice while 'poor' is counted once, but that number doesn't carry over beyond one repeat in any given category.
Sources consulted so far:
Solved: Repeat record counter in Survey123 - Esri Community
How To: Calculate the sum of repeats in ArcGIS Survey123 (esri.com)
Solved: Calculate sum of specific responses in repeat - Esri Community
The approach I have currently - it breaks the parser (probably because selected() returns Boolean values?), which I have not been able to sort out...
| begin group | defect_summary_s | | |
| integer | bad_section | Bad Sections | sum(count(selected(${tia_obs_section_safety},'unsafe')) + count(selected(${tia_obs_section_safety},'questionable'))) |
| integer | bad_foundation | Bad Foundations | sum(count(selected(${tower_foundation_cond},'hazardous')) + count(selected(${tower_foundation_cond},'poor'))) |
| integer | bad_grounding | Bad Groundings | sum(count(selected(${tower_grounding_cond},'hazardous')) + count(selected(${tower_grounding_cond},'poor'))) |
| integer | bad_bp | Bad Baseplatess | sum(count(selected(${tower_bp_cond},'hazardous')) + count(selected(${tower_bp_cond},'poor'))) |
| integer | bad_safety_climb | Bad Safety Climbs | sum(count(selected(${safety_climb_cond},'hazardous')) + count(selected(${safety_climb_cond},'poor'))) |
| integer | bad_guy_attach1 | Bad Guy Attach1 | sum(count(selected(${tower_ga_cond},'hazardous')) + count(selected(${tower_ga_cond},'poor'))) |
| integer | bad_guy_wire | Bad Guy Wires | sum(count(selected(${tower_wire_cond},'hazardous')) + count(selected(${tower_wire_cond},'poor'))) |
| integer | bad_rad | Bad Rads | sum(count(selected(${rad_mount_cond},'hazardous')) + count(selected(${rad_mount_cond},'poor'))) |
| integer | bad_equip | Bad Equips | sum(count(selected(${sector_equipment_cond},'hazardous')) + count(selected(${sector_equipment_cond},'poor'))) |
| integer | bad_rod | Bad Rods | sum(count(selected(${lightning_cond},'hazardous')) + count(selected(${lightning_cond},'poor'))) |
| integer | bad_antenna | Bad Antennas | sum(count(selected(${lone_antenna_cond},'hazardous')) + count(selected(${lone_antenna_cond},'poor'))) |
| integer | bad_light | Bad Lights | sum(count(selected(${light_cond},'hazardous')) + count(selected(${light_cond},'poor'))) |
| integer | bad_guy_attach2 | Bad Guy Attach2 | sum(count(selected(${guy_attachment_cond},'hazardous')) + count(selected(${guy_attachment_cond},'poor'))) |
| end group | defect_summary_e | | |
| | | | |
| hidden | issue_count | Number of issues reported: | sum(${bad_section} + ${bad_foundation} + ${bad_grounding} + ${bad_bp} + ${bad_safety_climb} + ${bad_guy_attach1} + ${bad_guy_wire} + ${bad_rad} + ${bad_equip} + ${bad_rod} + ${bad_antenna} + ${bad_light} + ${bad_guy_attach2}) |
I would greatly appreciate the advice of guidance of folks smarter than myself!