Randomisation and if statement

Hi,

I am trying to create a hidden value that will allocate cases to one of
three groups:

I first create a random integer from 1:3:
d0010_randnum = int(random() * 3) + 1

Then I create a second hidden value to allocate the case to a group:
d0011_randout = if((#form/d0010_randnum = 1), “Group_1”,
if(#form/d0010_randnum = 2, “Group_2”), “Group_3”)

Finally I display a label
"This participant has been randomised to: "

However, displayed label doesn’t appear to match the data saved.

Any suggestions greatly received.

Hi Peter,

Are you loading the “d0010_randnum” hidden value into a calculation
or a default
value
? Random values should be loaded into the default value, which is
only ever evaluated once when the form begins, which may correct the issue
that you’re seeing.

-Clayton

··· On Fri, Oct 20, 2017 at 9:24 AM, petermacp wrote:

Hi,

I am trying to create a hidden value that will allocate cases to one of
three groups:

I first create a random integer from 1:3:
d0010_randnum = int(random() * 3) + 1

Then I create a second hidden value to allocate the case to a group:
d0011_randout = if((#form/d0010_randnum = 1), “Group_1”,
if(#form/d0010_randnum = 2, “Group_2”), “Group_3”)

Finally I display a label
"This participant has been randomised to: "

However, displayed label doesn’t appear to match the data saved.

Any suggestions greatly received.


You received this message because you are subscribed to the Google Groups
"commcare-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to commcare-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thanks yes, was loading into a random number. Will change to default and see if that sorts it.
Much appreciated!