1. Home
  2. Survey
  3. Build Survey
  4. Question types
  5. Value assignment (professional user)
  6. RandBetween & RandomInt: Selection based on a random value

RandBetween & RandomInt: Selection based on a random value

Difficulty level: Difficult

All participants receive a survey consisting of, for example, 4 sections of questions: one section of general questions to be answered by each participant (i.e. the general section) and three sections of specific questions of which only one has to be completed by each participant (e.g. sections 1, 2 and 3). The latter sections may involve, for example, three different products, services or components, only one of which has to be assessed by each of the participants. Which section with specific product, service or component questions a participant has to answer, is determined by a random mechanism.

randBetween

This function in a value assignment determines which section of questions a participant has to answer.

In the example, a value between 1 and 3 is completely randomly attributed to the Random custom variable. The values 1 to 3 represent the sections 1 to 3, respectively.

  • Random is a variable name selected by you.
  • The corresponding data type is Integer number.
  • The randBetween(a,b) function can be recorded in the Is equal to the following term: box.

Separate filters can be set for the sections with specific questions.

Participants who are assigned the random value 1 when answering the survey, will see only the questions defined for section 1. When setting the filter for section 1, the following data can be recorded:

  • Show this element
  • IF – Custom variable – Random = 1

Once a participant has answered the section of general questions, the mechanism assigns a value to this participant, based on which it determines which section of questions he/she will be shown.

In this example, the filters for sections 2 and 3 are as follows:

randomInt

This function in a value assignment also determines which section of questions a participant should answer. However, there is a slight difference compared with the previous function.

In the example, the value 1 or 2 is completely randomly assigned to the Random custom variable. The values 1 to 2 represent the sections 1 to 2, respectively. The value 3 that would have been linked to section 3 in the randBetween function is excluded in the randomInt function. This is actually the only difference between this and the randBetween function.

To illustrate:

  • randBetween(1,4) returns the values 1, 2, 3 and 4, based on which 4 sections of questions can be created, only one of which is answered by a survey participant. It cannot be determined in advance which section that will be.
  • randomInt(1,4) returns the values 1, 2 and 3, based on which 3 sections of questions can be created, only one of which is answered by a survey participant. And again with this function, it is impossible to predetermine which section that will be.

And the same points below apply to this function:

  • Random is a variable name selected by you.
  • The corresponding data type is Integer number.
  • The randomInt(a,b) function can be recorded in the Is equal to the following term: box.
Updated on July 3, 2023
Was this article helpful?

Related Articles

Need Support?
Please login to your Survalyzer account and use the "Create Support Request" form.
Login to Survalyzer