Selecting a random subset of responses from different questions | XM Community
Skip to main content

Hi all,
I'm a Qualtrics newbie, so I apologize if my question is phrased poorly.
In my survey, I ask participants to recall 5 distinct events. For each event, they provide:
1) the location where it occurred
2) a person associated with the event
3) an object associated with the event
Screen Shot 2021-06-01 at 4.38.21 PM.pngTherefore, there are 5 events x 3 details = 15 details in total. What I would like to do is to randomly select 1 location, 1 person, and 1 object from the 15 details that participants provide. Additionally, each of the three selected details must be from a different event.
This can be visualized as an array (see below). Selecting a location from event 1, a person from event 3, and an object from event 4 satisfies my requirements. But any combination that selects multiple details of the same type (location, person, object) or multiple details from the same event does not.
image.png


Is there a way that I can accomplish this in Qualtrics? Please let me know if my question is unclear.

Unfortunately, there's not necessarily an easy way for you to do this. This "easiest" way I can think to do this without involving any JavaScript involves a rather lengthy set up (requires 15 branches to set up in the survey flow), but again, this requires no JS programming. The logic has a tree structure. Important note before I get started...the numbers that each embedded data field below are equal to are related to each of the 5 events. So, for example, Location = 1 refers to Location of Event #1.
All of this logic in the survey flow should be placed after the block where folks recall their events, and before the block where you bring up the random location, person, and object again. If you don't have these things in separate question blocks, you will need to split them into separate question blocks.
First, set up a random select of location like so:
Screen Shot 2021-06-02 at 10.24.45 AM.pngThen, set up 5 branches (below the location randomizer section above) for each Location # like so, to assign a Person event number that is NOT equal to location:
Screen Shot 2021-06-02 at 10.27.56 AM.pngNote that since Location = 1, I do NOT have Person = 1. When you set up the branch for Location = 2, do NOT have Person = 2, and so on and so forth for the rest of the Location branches.

Next, set up 10 branches (below the Location branches from the step above) for each unique Location # + Person # combination like so, to assign an Object event number that is NOT equal to either Location or Person:
Screen Shot 2021-06-02 at 10.40.05 AM.pngAgain, note that since Location = 1 & Person = 2, I do NOT have Object = 1 or Object = 2.

Okay, now that you have that randomization scheme all set up, we're going to replace our numbers in the embedded data fields with piped text instead. So, instead of "1" for the Location variable, I'm going to replace "1" with the input that my participant gave for Event 1 Location, using the Piped Text menu; instead of the "2" for the Person variable, I'm going to replace "2" with the input that my participant gave for the Event 2 Person, using the Piped Text menu...and so on and so forth. Do this for ALL numbers.

Then, when you need to bring up your random "Location", "Person", and "Object" in the survey, use the following piped text to produce the participant's random location, person, and object that you selected:
${e://Field/Location}
${e://Field/Person}
${e://Field/Object}

It's also a good idea to test your randomization scheme set up using the generate test data function in your survey, both before and after you update your numbers to piped text-- just to make sure that the assignments are working correctly.

Let me know if you would like any clarifications!











@AHammell Wow, thank you so much for taking the time to think through this problem and provide a detailed explanation of how to implement a solution in Qualtrics! The images help a lot, too! I'm going to read through your post carefully and see if I can get my survey working as intended.
I imagine that I could accomplish this more "elegantly" using Javascript (maybe with nested loops? I'm not a CS person), but my JS knowledge is very rudimentary at the moment. So your Qualtrics-based solution is just what I was looking for.


@AHammell Okay, I think I got everything working per your instructions. The survey flow is a bit messy, but (as far as I can tell) it functions as intended!
One question: you mentioned using the generate test data function to ensure the assignments are working correctly. I tested 50 iterations and got 50 saved responses. Does this mean that no problems were encountered?
Screen Shot 2021-06-02 at 11.20.06 PM.pngThanks again for your help!


Looks like the test data was successfully generated! All I would recommend you do now is download your data and ensure there is approximately an equal number of "test" folks assigned to each event for the Location, Person, and Object variable (unless equal assignment is unimportant to you). For example, seeing that there is an approximately equal number of folks who were selected for Event #1, #2, #3, #4, and #5 for the Location variable (and then doing the same for the Person embedded data variable and the Object embedded data variable).


Leave a Reply