Select to view content in your preferred language

Conditional constraint for an integer question

193
1
03-25-2026 10:10 AM
Strahanjen
Frequent Contributor

I am looking for help with writing a conditional constraint. What I've tried so far is not working. 

This is for a stream monitoring survey. The user is asked to report which stream features are present in a reach (pool, riffle, run, glide), as well as the prominent substrate types within each feature. For each feature present in the reach, we also want to know the percentage of the reach that feature comprises. The form looks like this: 

 

Screenshot 2026-03-25 115323.png

If the user fills in a percentage, I want to ensure that the user selects at least one substrate type. This one is easy, I put a required condition on the substrate multiple select question that looks like this: if(${iz_pool_percent}>0,true,false)

The part I am struggling with is, if the user selects substrate types present for a particular stream feature, ie. pool in the example above, we want to ensure that the user fills in a corresponding percentage for % Pool. I cannot use a condition to make % Pool required in this instance, because it creates a circular dependency because I have the question above set to be required if the user enters a percentage. So, I thought I could use a constraint for % Pool that looks like the following.

if(count-selected(${iz_sub_pool})>0,${iz_pool_percent}>0,${iz_pool_percent}=0)

This is not working. When I try to submit the survey, I do not get a constraint error. Maybe someone can help me understand what I'm missing? 

The relevant part of my survey123 connect file is attached.

0 Kudos
1 Reply
Neal_t_k
MVP Regular Contributor

What if you had a select multiple question first, with options for Pool, Riffle,etc.  asking which are present at the site, then have each pair of questions relevant on the selection. Then each pair can just be required and will only need to be answered when relevant.

0 Kudos