How to add a step to my embedded rand int | XM Community
Skip to main content
Solved

How to add a step to my embedded rand int

  • January 10, 2020
  • 11 replies
  • 16 views

Hello, I have added an embedded data set to my survey and have piped it into my question, but I don't want a random integer pulled from the whole list, I want it in increments of 15. Is there a way I can add a step to the rand int function?

Best answer by TomG

@JessYork, 125 isn't a multiple of 15, but to get a random number between -120 and 120 in increments of 15: !

11 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • January 10, 2020
One possible way is to create custom external service API which gives random number with step 15

  • Author
  • January 10, 2020
That is out of my wheelhouse. How can I do it from this? ${rand://int/-125:125}

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • January 10, 2020
> @JessYork said: > That is out of my wheelhouse. How can I do it from this? ${rand://int/-125:125} It just provide min and max but not steps

  • Author
  • January 10, 2020
So there is no way to add a step counter to this? ${rand://int/-125:125}

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • January 10, 2020
> @JessYork said: > So there is no way to add a step counter to this? ${rand://int/-125:125} no

  • Author
  • January 10, 2020
Maybe, if this doesn't work, is it possible to change the embedded data to pull randomly from an array? Such as {-125, -110, -95,..., 95, 110, 125}

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • January 10, 2020
> @JessYork said: > Maybe, if this doesn't work, is it possible to change the embedded data to pull randomly from an array? Such as {-125, -110, -95,..., 95, 110, 125} Great thought! It is possible but in this case the one random number can get assigned to many respondent. Is that fine?

  • Author
  • January 10, 2020
you know, I haven't thought of that. That is something I will need to discuss with my professors for the project but I think it will work out where every number will get assigned multiple times, I guess I'd probably want them evenly distributed to respondents

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • Answer
  • January 10, 2020
@JessYork, 125 isn't a multiple of 15, but to get a random number between -120 and 120 in increments of 15: !

  • Author
  • January 13, 2020
That worked perfectly, @TomG . For another set of questions, I will need to pull the value that was given to the recipient and either double it or halve it (depending on the question). Can I ensure that they get the same value and put it into the subsequent questions?

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • January 13, 2020
> @JessYork said: > That worked perfectly, @TomG . For another set of questions, I will need to pull the value that was given to the recipient and either double it or halve it (depending on the question). Can I ensure that they get the same value and put it into the subsequent questions? Sure, add these variables after you set rand: double_rand = $e{ e://Field/rand * 2 } half_rand = $e{ e://Field/rand / 2 } Since some of the rand value are odd numbers, some of the half_rand numbers will have decimals. BTW, you should accept my first answer.