How do I generate a random integer between 6 and 9 and -6 and -9 that I use as a loop and merge fiel | Experience Community
Skip to main content
Solved

How do I generate a random integer between 6 and 9 and -6 and -9 that I use as a loop and merge fiel

  • February 25, 2022
  • 6 replies
  • 544 views

Forum|alt.badge.img+2

Hi there,
How do I generate a random integer between 5 and 9 and -5 and -9 that I use as a loop and merge field?
Now the command ${rand://int/(5:9||-5:-9)} does not seem to work.

Thank you

Best answer by Tom_1842

True about the math operations! I went with the Piped Text option (insert Piped Text -> Random Number -> Integers) to generate the random numbers
InsertRandomNumber.png

View original

6 replies

Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31

Hi aphdts You can use Math.random() in order to generate random numbers. However can you please elaborate more on your use case such that we can work on it accordingly


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • February 25, 2022

Hi there, you can also use the Randomizer element and RandomNumber generator in the Survey Flow to generate specific ranges of random numbers, like in the below:
randnumber_specificranges.png


Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31

You would need to use Javascript in the block before you use the randomizer in the survey block and store the values in the embedded data randnumber as a workaround to view the random numbers.

Qualtrics does not support random number generation as a math operation:

https://www.qualtrics.com/support/survey-platform/survey-module/editing-questions/piped-text/math-operations/#MathOperationsSyntax


Tom_1842
Level 8 ●●●●●●●●
Forum|alt.badge.img+28
  • Level 8 ●●●●●●●●
  • Answer
  • February 28, 2022

True about the math operations! I went with the Piped Text option (insert Piped Text -> Random Number -> Integers) to generate the random numbers
InsertRandomNumber.png


Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31

That's great! That a new learning for me :-)


Forum|alt.badge.img+2
  • Author
  • February 28, 2022

Thank you both Aanurag_QC and Tom_1842
I used the piped text option (insert Piped Text -> Random Number -> Integers) and it works ok!