Randomly selecting a subset of selected answer categories
Problem
You want to select a random combination of answers provided to a multiple-answer question.
Solution
Use a CALCUL question with an expression like the following:
where
Discussion
Sometimes, it is necessary to select a random subset of answers provided to a multiple-selection question. An example would be to randomly select two magazines among a list of magazines selected by the respondent. The special function random_subset is used for this purpose.
This function selects a random subset of the answers provided and returns the result as a value that can be used on another multiple-selection question. If the respondent originally offered fewer answers than required in the random subset, all of their answers will be included in the "random subset".
The result of this function can be used in display conditions as if it had been produced in response to a multiple-selection question.
It is possible to randomly select a single answer as well (e.g., RANDOMSELECTION = random_subset($MULTIQ,1)); such a selection would be stored in a single-answer question, not a multiple-selection question.