# Applying Constraint on Multiple select depending of previous field value

**URL:** <https://forum.getodk.org/t/applying-constraint-on-multiple-select-depending-of-previous-field-value/23823>\
**Category:** Support\
**Created:** [December 10, 2019, 7:42am UTC](https://forum.getodk.org/t/applying-constraint-on-multiple-select-depending-of-previous-field-value/23823 "2019-12-10T07:42:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Samuel\_Kamiru](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_kamiru/32/9754_2.png) [@Samuel\_Kamiru](https://forum.getodk.org/u/Samuel_Kamiru)\
**Post date:** [December 10, 2019, 7:42am UTC](https://forum.getodk.org/t/applying-constraint-on-multiple-select-depending-of-previous-field-value/23823/1 "2019-12-10T07:42:36Z")

</div>

I am building an ODK tool using xlsForms; however, I have a requirement that has proven difficult to address.  
How does one implement constraints depending on a previous field? e.g.

1. Sex  
☐ Male  
☐ Female  
☐ Unspecified
2. Which priority population group(s) (Select all that apply)  
☐ Adolescent girls ( **if female** )  
☐ Low SES  
☐ Vulnerable women ( **if female** )  
☐ Long-distance truck drivers  
☐ Migrant workers  
☐ Pregnant women ( **if female** )  
☐ Other: (Specify: \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_)

If the choice in Q1 is male; it restricts "if female" choices. Kindly advise how best to implement the solution.

Thank you!.

Thank you!

---

<div class="post-metadata">

**Author:** ![aurdipas](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/aurdipas/32/1785_2.png) [@aurdipas](https://forum.getodk.org/u/aurdipas)\
**Post date:** [December 10, 2019, 8:35am UTC](https://forum.getodk.org/t/applying-constraint-on-multiple-select-depending-of-previous-field-value/23823/2 "2019-12-10T08:35:23Z")

</div>

Dear @Samuel_Kamiru,

what you are looking for is "[Filtering options in select questions](https://docs.opendatakit.org/form-logic/#filtering-options-in-select-questions)".  
Please look at the link, where you can find examples of how to implement it.

Best,  
Aurelio

---

<div class="post-metadata">

**Author:** ![Samuel\_Kamiru](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_kamiru/32/9754_2.png) [@Samuel\_Kamiru](https://forum.getodk.org/u/Samuel_Kamiru)\
**Post date:** [December 10, 2019, 10:24am UTC](https://forum.getodk.org/t/applying-constraint-on-multiple-select-depending-of-previous-field-value/23823/3 "2019-12-10T10:24:02Z")

</div>

@aurdipas Thank you for the feedback. The challenge with the solution you provided would work in one direction; however, there are **options/choice** s that are applicable for both Males and females. i,e. The ones that are not indicated **if females**

---

<div class="post-metadata">

**Author:** ![aurdipas](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/aurdipas/32/1785_2.png) [@aurdipas](https://forum.getodk.org/u/aurdipas)\
**Post date:** [December 10, 2019, 10:55am UTC](https://forum.getodk.org/t/applying-constraint-on-multiple-select-depending-of-previous-field-value/23823/4 "2019-12-10T10:55:32Z")

</div>

you can use OR on the choice filter.

See the extended example

[Jobcategories.xlsx](https://forum.getodk.org/uploads/short-url/jJeA4QzzVoEw6BrUe4zNOTjv7fy.xlsx) (11.6 KB)

---

<div class="post-metadata">

**Author:** ![Samuel\_Kamiru](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/samuel_kamiru/32/9754_2.png) [@Samuel\_Kamiru](https://forum.getodk.org/u/Samuel_Kamiru)\
**Post date:** [December 11, 2019, 10:31am UTC](https://forum.getodk.org/t/applying-constraint-on-multiple-select-depending-of-previous-field-value/23823/5 "2019-12-11T10:31:36Z")

</div>

@aurdipas Thank you very much. The solution works!
