Counting the number of all options in a select_one / select_multiple variable

Actually, there is a 'trick'... :wink:. If you randomize the choices the XForm will turn them into a nodeset, which you can then use the XPath count() function to count how many there are.

Have a play with this form in https://opendatakit.org/xlsform/

count-choices.xls (19.5 KB)

[Update] You can also trigger turning the choices to a nodeset with a simple choice_filter, which avoids randomizing your choices... A simple no-op filter like true() will suffice

count-choices2.xls (20 KB)

[this trick courtesy @LN :wink: ]

3 Likes