Help with randomly selecting eligible respondents

I am building a form in .xls and there an areas where I need to list all the members of the household and then randmly auto-select an eligible respondent. For example, after listing all the household members without minding their ages and sex, I need to select one that is between 18 & 45 years old and has a child that is 6-23 months old and have name of the selected monther and child appear.
Can I get help for this please?
Thanks

So you have a lot of data capture going on here... It would help if you could explicitly enumerate precisely what data you are acquiring, and in what format is it being saved. Then perhaps we can determine how best to display a suitable random subset thereof.

Thanks Xiphware and everyone. Below is what I was trying to describle.
snippet
Unfortunately this is the what comes up after the randomization instead of giving me the name of the eligible mother to interview after completing the tool. There are 3 eligible mothers in the household.

Its appears from your form that you already have an elig_female calculation, which will either be the name of the (eligible) individual, or null if they do not meet the criteria. Given this, you can construct a list of the names of all the eligible females after your repeat group, by using the join() function (with a space separator); eg

eligible_list: calculation = join(' ', ${elig_female})

You could then determine if there was anybody eligible by:

count-selected(${eligible_list) > 0

and if so, select a random one from this list something like using

selected-at(${eligible_list}, int(random()*count-selected(${eligible_list)))

Give it a go, and please report back if it works! :slight_smile:

Many thanks, I got it yesterday. The last 2 steps were the missing links but I was able to pull through.
Best regards.

Awesome. If you could please share your working solution so that other folks that land here can benefit. Thanks! :slightly_smiling_face:

Thanks so much Xiphware. THis was one nightmare that kept me awake. I eventually broke it with the help of other on this platform and I hope others can also learn. I had been trying to select an eligible mother from the list of eligible mothers to further interview in the household. As a background this is intended for use in settings where polygamy is widely practiced. So first, I enrolled all the people in the household and then calculated the eligible females. I constructed the list of all eligible members by join(' ', ${elig_female})
Next was to do a count of all eligible mothers using count-selected(${listgirspos})
FInally I picked an eligile mother with the code selected-at(${listgirspos},int(${select_among}*${n_selected}))
Then I created a note that gave me the name of the selected among the eligible mothers.
ALso attached is the worksheet with detail solution. I hope someone else benefits.
Thanks.
Book2.xlsx (11.2 KB)

Thank you so much for this. I want to do a similar thing but I want to randomnly select 10 members from the list. Please how do I go about that, has anyone tried it before?