Randomly Choose a Name from a Household Roster

Dear all,

Does anyone can help me to choose a random name from a household roster and appearance in text?

Highly appreciate if somebody assist me....

Thank you,

Dev

Hi Dev, Can you provide some more details about your use case?

  • You need to choose a random name from a list included with your form? Or a random name from data provided as a form is being filled out?
  • Each row in your list is a household and the name is the household representative, and you need to select one? Or each row is a household member and you need to select a random household member from a given household in the list?
  • Once you choose the name, how are you using it? What is(are) the next question(s)?

Dear Dan,

Thank you for response. Maybe I could not make clear which i posted before...I will try to clear.
For example: I need to interview a girl who is between age of 18-25 from a household.
Suppose there are 3 girls between age of 18-25 the named AAA, BBB and CCC in a household.
I can build a household roster using "BEIGN REPEAT" command where I can input all family members.
Now I want to choose a girl for a complete indiviual interview either AAA or BBB or CCC by random
selection with appearance in text like "BBB" is selected (Suppose the "BBB" named girl is selected in random selection).
I mean I want to choose a random name from household roster with text apperance in next screen among of these three girls.

I hope now I can make clearer...could you please tell me about the process?

Dev Maharjan

Sorry Dev, I'm not sure how to implement that. Best of luck and please let us know if you find something that works!

Did you try out some of the suggestions in Select an 5-15 years old household member randomly?

Dear Hélène Martin,

It worked well to select a member in a number hence we need to back to view the selected ith number girl's name so I want to view the selected girls name instead of number. I haven't tried to view the name of selected person.

Many thanks

Dev

Great! It's a little hard for me to tell without looking at your form but I think you can use the indexed-repeat function for that.

For example, if the repeat in which you collected participant names is called ${participants} you could introduce a calculate with calculation that is something like indexed-repeat(${name}, ${participants}, ${selected_index}). I think you can also do this with straight XPath but the function is probably a little easier.

Dear Hélène Martin

Thanks a lot for responding but I was not involved for the last few weeks in the forum. I will try to share with an example in near future.

Cheers,

Dev

1 Like

hi @Dev
if i get you right by your issue, i have work on a sample file base on the information you have provided below.

please test this dev_sample.xlsx (44.9 KB)
sample file and let us know whether it solve you issue or not. sorry for the delay in reply, i just saw it today.

Thanks
fabla2020@gmail.com

3 Likes

Thanks @Fabla for your always insightful examples! I believe @debu_odk needs to capture all household members and then only consider the women between 18-25 when choosing a random respondent. Your example only allows for up to 4 women's information to be captured.

@debu_odk it sounds like you've been able to get the form working as you wanted with the information above. Could you please post what you have come up with so others can learn from it? This will particularly help @billowabdi who was looking for a similar example in Randomly Selecting a Respondent from Household Members.

1 Like

Dear Abdul-Majeed

Thanks for your response. Sorry to tell you that I was too busy at official work in the last few weeks so I couldn't try what you posted on the forum for my issue. I will try and then post in the forum.

Cheers

Dev

hi @LN
I didn't look into those women between the age of 18 to 25 years, i only consider women more than or equal to 18 years, that is true,

we can still make it possible to pick up only girls between the ages of 18 to 25 years and randomly interview them. just as we did for the gender.

for the number of women which are allow to stand the chance of being randomly selected is limited to 4 women who are more than or equal to 18 years. you can increase the number to any number you want by adding more calculations to the index repeat number. all the household members are captured by the repeat group question.

thank
fabla2020@gmail.com

1 Like

Here is a form based on @Jguzman2's excellent example that puts all the pieces together. This strategy will work for collecting information on all household members and will only consider eligible people, no matter how many there are.

You may notice that indexed-repeat(${name}, ${hh1}, if(${selectedWoman} != null, ${selectedWoman}, 1)) is a little more complex than what I had suggested above. That's because of a limitation described under the heading "indexed-repeat failure before adding 2nd repeat group" here. @Megan_Schroeder brought this up in Indexed-Repeat Error for previously defined integer as the third argument and it will be fixed in the next Collect release such that the if will no longer be necessary (but it will be fine to leave it in).

You can certainly "unroll" things as @Fabla did but keep in mind that it requires you to make hard assumptions on the maximum number of possible eligible people and will result in more columns in the dataset.

3 Likes