1. What is the issue? Please be detailed.
I am designing an XLS form and want to use it to randomly select one participant from a household. If the first participant selected declines to participate, I want to refresh the random number generator to select a second participant within the household to attempt to enroll.
I have successfully built the random number generator, but don't know how to set it up so that it can be run a second time, or if it's even possible?
2. What steps can we take to reproduce this issue?
I am attaching a sample XLS form below that shows my current code. I have one integer field where the enumerator can record the number of eligible people, one calculate field that calculates a random number between 1 and the number eligible, and one note field that displays the results of the random number generator to the enumerator.
3. What have you tried to fix the issue?
I have tried to search for resources or posts that address this issue, but haven't been able to find anything. Would appreciate any help on the topic, thank you!
4. Upload any forms or screenshots you can share publicly below.
Sample XLS Form_random number.xls (27.5 KB)
Welcome to the ODK forum. We're glad you're here. When you get a chance, please introduce yourself on this forum thread. I'd also encourage you to add a picture as your avatar because it helps build community!
What if the second participant declines too? Should the number be generated again and again or maybe you want to give only one chance to generate the number again?
Hi! So I actually did identify a work around solution to this by creating multiple random number generator fields, rather than attempting to refresh the first one.
After the first random number is generated, we have a field that asks whether or not the first participant consented. If the answer is No, then that person would be allowed the leave, the numbered cards we plan to use would be redistributed between the remaining eligible participants, and a new field will generate a random number in between 1 and 1 less than the total number of eligible household members.
Given the particulars of our study design, we would like to have the option of repeating this process until someone in the household consents (not stopping at two chances), so this workaround would require a large number of random number generator fields to account for the possibility of large households, which isn't ideal.
What I'm actually interested in doing instead now is creating a field that generate a randomly re-ordered, comma-separated list of the household member numbers, so that the process described in my last comment is condensed into just one field and the enumerators can simply go down the list of numbers.
For example, if there are 4 eligible household members, I would like a field that generates a list like "2, 1, 4, 3".
Should I create a new question for this problem? Do you have any ideas about how to address it? Thank you!
Yes, I think it would be better to start a new topic. If you were able to solve the problem you described initially please add the form you created so that other users can find it if they have similar problems to solve.