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

How to add a step to my embedded rand int

  • Jan 10, 2020 4:04 AM UTC
  • 11 replies
  • 53 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: !
View original

11 replies

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

  • Author
  • Jan 10, 2020 4:40 AM UTC
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 ●●●●●●
  • Jan 10, 2020 5:17 AM UTC
> @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
  • Jan 10, 2020 5:19 AM UTC
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 ●●●●●●
  • Jan 10, 2020 5:22 AM UTC
> @JessYork said: > So there is no way to add a step counter to this? ${rand://int/-125:125} no

  • Author
  • Jan 10, 2020 5:26 AM UTC
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 ●●●●●●
  • Jan 10, 2020 5:28 AM UTC
> @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
  • Jan 10, 2020 5:35 AM UTC
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
  • Jan 10, 2020 4:35 PM UTC
@JessYork, 125 isn't a multiple of 15, but to get a random number between -120 and 120 in increments of 15: !

  • Author
  • Jan 13, 2020 8:53 PM UTC
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 ●●●●●●●●
  • Jan 13, 2020 9:10 PM UTC
> @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.