How do you dynamically update variables in a loop | XM Community
Skip to main content

Hello
I am building an experiment that involves repeated trials where I provide 3 input numbers (VAR1, VAR2, VAR3) that are each a random number between 1 and 25. An output is calculated on the subsequent page.
For each trial, I would like VAR1, VAR2 and VAR3 to recalculate as newly generated numbers. I would like to save these as well as the subsequent page of model output for each trial.
When I use the loop and merge function at the moment however, every trial is still showing the same original VAR1, VAR2, VAR3 calculated.
How do I get these to dynamically update instead?
Thank you

If you need to save VAR1, VAR2, VAR3 in your response data, you can generate them for each loop (e.g., VAR1_1, VAR1_2, etc.) and add them as fields in your loop & merge setup.


Hi Tom, could I please trouble you for a bit more detail on how you can add them as fields in the loop and merge setup? Thank you


Pipe them into the loop & merge fields like:
Field1 Field2 Field3
1 ${e://Field/VAR1_1} ${e://Field/VAR2_1} ${e://Field/VAR3_1}
2 ${e://Field/VAR1_2} ${e://Field/VAR2_2} ${e://Field/VAR3_2}
...etc...


Thanks Tom, this was just what I needed


Leave a Reply