How to randomize multiple fields in loop and merge | XM Community
Skip to main content
Solved

How to randomize multiple fields in loop and merge

  • March 26, 2018
  • 1 reply
  • 173 views

Hi there, I'm having problems to randomize two fields in loop and merge. And I would appreciate any help or suggestions here! : ) So I have a loop and merge block that contains two elements, as in Field 1 and 2 respectively: Field 1 - abc, def, ghi, klm Field 2 - A, B, C, D Field 1 is text descriptions, Field 2 is numbers How can I get a random combination of both fields (e.g. abc+A, def+A, ghi+C...), and shown randomly to participants using loop and merge? Btw, there are over 100 survey questions in this block. And the numbers have to be displayed at a fixed rate (e.g. 20%A, 30%B, 15%C...etc). Is this set-up too complicated to use loop and merge alone? Thanks so much for your kind help in advance!

Best answer by TomG

You can't. In loop 1, you can only access abc and A, in loop 2, def and B, etc. You'll have to set it up another way. You can loop over the text fields, but the numbers can't be in a loop and merge field unless they are randomly predetermined and piped into a loop & merge field. Since the numbers have to be used in different percentages, you'll have to use either a web service or JavaScript to set an embedded data field(s) to the number either before (if using a web service) or at the beginning (if using JavaScript) of your loop. The easiest way would be to use a simple randomize function and trust that with enough responses it will work out to the percentages you are looking for. If you need tighter control, you can pipe quotas into your web service or JavaScript and determine the number(s) based on your current quota counts.
View original

1 reply

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • Answer
  • March 26, 2018
You can't. In loop 1, you can only access abc and A, in loop 2, def and B, etc. You'll have to set it up another way. You can loop over the text fields, but the numbers can't be in a loop and merge field unless they are randomly predetermined and piped into a loop & merge field. Since the numbers have to be used in different percentages, you'll have to use either a web service or JavaScript to set an embedded data field(s) to the number either before (if using a web service) or at the beginning (if using JavaScript) of your loop. The easiest way would be to use a simple randomize function and trust that with enough responses it will work out to the percentages you are looking for. If you need tighter control, you can pipe quotas into your web service or JavaScript and determine the number(s) based on your current quota counts.

Leave a Reply