# Counting the number of all options in a select\_one / select\_multiple variable

**URL:** <https://forum.getodk.org/t/counting-the-number-of-all-options-in-a-select-one-select-multiple-variable/17393>\
**Category:** Support\
**Tags:** form-design, odk-xlsform\
**Created:** [January 22, 2019, 1:20pm UTC](https://forum.getodk.org/t/counting-the-number-of-all-options-in-a-select-one-select-multiple-variable/17393 "2019-01-22T13:20:56Z")\
**Posts on this page:** 1\
**Showing post:** 28

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [October 1, 2019, 8:46am UTC](https://forum.getodk.org/t/counting-the-number-of-all-options-in-a-select-one-select-multiple-variable/17393/28 "2019-10-01T08:46:56Z")

</div>

Actually, there is a 'trick'... 😉. If you randomize the choices the XForm will turn them into a nodeset, which you can then use the XPath [count()](https://docs.opendatakit.org/form-operators-functions/#count) function to count how many there are.

Have a play with this form in [https://opendatakit.org/xlsform/](https://opendatakit.org/xlsform/)

[count-choices.xls](https://forum.getodk.org/uploads/short-url/95ThXNds9JVan7umiBGOkYmcRVr.xls) (19.5 KB)

[Update] You can also trigger turning the choices to a nodeset with a simple [choice\_filter](https://docs.opendatakit.org/form-logic/#filtering-options-in-select-questions), which avoids randomizing your choices... A simple no-op filter like `true()` will suffice

[count-choices2.xls](https://forum.getodk.org/uploads/short-url/kl5kNaFy2vcD3sG0VM44hDP3NjA.xls) (20 KB)

[this trick courtesy @LN 😉]

---

_[View the full topic](https://forum.getodk.org/t/counting-the-number-of-all-options-in-a-select-one-select-multiple-variable/17393)._
