Hi All
Greetings
I have a household listing application, where household members data is being collected.
After roster finishes, i have a summary question "linenumber_child" . In this variable, i want eligible child line number automatically from the roster.
Eligible child definition is:
Child_age in 0:23 and mother_line>0 (Meaning mother exist), if both conditions are true, this is eligible child.
Now there may be more than one eligible child with these eligibility.
2 questions:
how to select one child line number randomly from all available eligible children in the roster.
or
how to select first eligible child from the roster.
Please suggest and help.
Thanks and Regards
Manoj
randomly selection of eligible participant from the roster
-
- Posts: 166
- Joined: November 21st, 2022, 4:41 pm
Re: randomly selection of eligible participant from the roster
Hello,
This answer on the forum should help with randomly selecting from a list of valid participants. This is a very common question, so if you follow the links provided you will see many different answers for how to select a random eligible group from a roster. Finding the first eligible participant in the roster just means ordering it as you need, using a for loop over the roster or list to find rows which match, and then simply exiting the for loop the first time you find something that matches. For random you could instead put the index of every row that matches in a list of eligibles, then randomly select from this new list.
Hope this helps,
Justin
This answer on the forum should help with randomly selecting from a list of valid participants. This is a very common question, so if you follow the links provided you will see many different answers for how to select a random eligible group from a roster. Finding the first eligible participant in the roster just means ordering it as you need, using a for loop over the roster or list to find rows which match, and then simply exiting the for loop the first time you find something that matches. For random you could instead put the index of every row that matches in a list of eligibles, then randomly select from this new list.
Hope this helps,
Justin