How to add a step to my embedded rand int | XM Community
Skip to main content
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?
One possible way is to create custom external service API which gives random number with step 15
That is out of my wheelhouse. How can I do it from this? ${rand://int/-125:125}
> @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
So there is no way to add a step counter to this? ${rand://int/-125:125}
> @JessYork said:

> So there is no way to add a step counter to this? ${rand://int/-125:125}



no
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}
> @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?
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
@JessYork,



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

!
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?
> @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.

Leave a Reply