How to draw two random numbers (without returning) from a pool of numbers
Example: There is a pool of numbers: 1, 22, 313, 414, 559 (subsequently called “pool“). Your goal is to draw two of them, randomly selected (random numbers).
Add two User-defined variables to your project: Survey menu >> Project properties >> User-definded variables: 2, save, Labels and Data type: set them to Integer, and name them, i.e. random1, random2 save.
Create a static list: Questionnaire editor >> Lists >> Create static list give a name, i.e. Pool save. Add as many list elements as there are elements in the pool, here: five. Inclusion condition: Always in random selection. Change list element no. accordingly to your pool numbers.
In Questionnaire editor add a List trigger at a point before the random numbers are needed: Triggers >> give a name, i.e. random numbers, activate: List trigger, click on button: Create. Settings of trigger: Also execute trigger in preview mode: activate, (other settings according to individual needs)
save. Detail configuration: Select your list: Pool Add two New List Elements:
List element List Property Target variable
List element 1 Label random1 (c_0001)
List element 2 Label random2 (c_0002)
List options: activate (!) the radio button and insert a 2 in the line „list elements will be selected at random.“ acitivate: Randomize list elements. Save.
Now you have two randomly selected numbers from your pool in the variables c_0001 and c_0002.
Keep in mind that our example is for 2 numbers. If you need more numbers you need to create for every number a user-defined variable, and extend the list trigger accordingly. Furthermore you can increase the pool by adding more list elements to your static list. The number of numbers in the pool is limited to 250 (maximum list size of a static list). The numbers in the pool can also be negative (if Label is used). In the static list, you can also use the element numbers by choosing Element Number in the list trigger. However, the element numbers are limited to 999.