# Random selection within ODK

**URL:** <https://forum.getodk.org/t/random-selection-within-odk/9324>\
**Category:** Support\
**Tags:** form-design, odk-collect, odk-xforms, odk-xlsform\
**Created:** [August 7, 2017, 1:54pm UTC](https://forum.getodk.org/t/random-selection-within-odk/9324 "2017-08-07T13:54:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![samlevins](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@samlevins](https://forum.getodk.org/u/samlevins)\
**Post date:** [August 7, 2017, 1:54pm UTC](https://forum.getodk.org/t/random-selection-within-odk/9324/1 "2017-08-07T13:54:06Z")

</div>

Dear Collegues,  
Am Sam from Uganda and currently working on a project where i need to randomly select 3 persons from a household roster using ODK. So i add people to a household and from that list of household members; i have to randomly select 3 persons (specific criteria needed for these people). Any Ideas!

Thanks  
samlevins

---

<div class="post-metadata">

**Author:** ![samlevins](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/s/f6c823/32.png) [@samlevins](https://forum.getodk.org/u/samlevins)\
**Post date:** [August 7, 2017, 2:27pm UTC](https://forum.getodk.org/t/random-selection-within-odk/9324/2 "2017-08-07T14:27:55Z")

</div>

I have been able to put all my eligible household members into one pool eg {1 2 3 4 5 6 7 8 9}  
Am thinking of 2 possible ideas moving forward;  
1: Randomly sort that list and then select the first 3 items in the list--Still not sure how to implement  
2: Randomly select the 3 members directly from the list-- the code i have for can randomly select only 1 person (once(int(random()\*count-selected(${pool})))) which may need to be customized to allow for 3 persons.

Still need help Please!

---

<div class="post-metadata">

**Author:** ![Aizik](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/aizik/32/12766_2.png) [@Aizik](https://forum.getodk.org/u/Aizik)\
**Post date:** [May 1, 2019, 10:31am UTC](https://forum.getodk.org/t/random-selection-within-odk/9324/3 "2019-05-01T10:31:20Z")

</div>

Hi Sam,  
I am having similar issue. My I ask how did you put the eligible household members in a pool please. I need to select one and don't know exactly how to go about it.  
Aizik form Nigeria

---

<div class="post-metadata">

**Author:** ![JosephKi](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/josephki/32/10888_2.png) [@JosephKi](https://forum.getodk.org/u/JosephKi)\
**Post date:** [June 11, 2020, 6:28am UTC](https://forum.getodk.org/t/random-selection-within-odk/9324/4 "2020-06-11T06:28:17Z")

</div>

Hi Sam,  
Sorry that am seeing this late. But I think I have a solution which may help others. What you've described is complete to pick a member with simple random sampling (SRS). To select other members, they're statistically many other ways - but the easiest is to base on the selected member and then select for instance every 2nd in order to add the other 2 members and have the list of three

> [@samlevins](#):
>
> my eligible household members into one pool eg {1 2 3 4 5 6 7 8 9}

I can see that you had generated a list to pick from, say if the random member is one in position 2; then additionally pick 4 and 6 in case its every 2nd; or pick 4 and 7 in case its every 3rd. That way, the one you pick first provides the random start and thus every other systematic pick remains at random in the list.

To achieve this in the form, include calculate fields that contain the names of members depending on their position - each member a variable. Ounce its the selected position, then call the respective member.

Hope it helps

---

<div class="post-metadata">

**Author:** ![Ebrahim](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/e/977dab/32.png) [@Ebrahim](https://forum.getodk.org/u/Ebrahim)\
**Post date:** [September 9, 2025, 6:41pm UTC](https://forum.getodk.org/t/random-selection-within-odk/9324/5 "2025-09-09T18:41:18Z")

</div>

Can you please share an example?  
I want already selected or default selected 3 random choices from the list
