How do I end a loop & merge once certain conditions are met? | XM Community
Skip to main content
I have a question that loops depending on the number of items chosen in a previous question. The first item (oldest child in this case) which meets a certain set of conditions will be chosen. If not, then the survey will move onto the next item, etc. I don't want to continue asking about the remaining items once the conditions are met. I can add skip logic to each question to skip to the end of the block, however, the loop still applies to the remaining items regardless of how the questions are answered. Can I end a loop and merge once certain conditions are met?
Documentation on loop & merge is found here.



Perhaps you can explain further what you are looking to do?

What is loop & merge currently doing that you don't want it to do?

What exactly is the desired action you are trying to get the loop & merge to do?
Thank you!



Here is my example:



Q1: How many children do you have between the ages of 2-5 years old?

R1: Multiple choice (1-4)



Loop & Merge based on the numerical response from Q1

Q2: Provide information about your oldest (or second oldest, third oldest, youngest) child (piped text from Q1)

R2: Name of child



Q3 - Q5: Does this child have the following conditions......(3 separate questions)

R3 - R5: Yes or No



If the respondent answers "yes" to any of Q3-Q5, then we move onto the next child and so on until the end of the number of children included in Q1. If the answer "no" to Q3-Q5 for the first child (or subsequent child), then I want the loop to end since this child is eligible and I don't care about the responses for the remaining children. We are recruiting the oldest eligible child.



So once the conditions of the child not having any conditions asked about in Q3-Q5, I don't want the loop & merge to continue. Is this possible?
You can use JavaScript to set an embedded data variable inside the loop when the condition is met and use that embedded data variable in display logic for every question within the loop.
Thank you - I am not a programmer 😞. Does anyone have an example this JS they would be willing to share?
I am also not a programmer, but I am posting an answer I found in case it helps someone else. The first JS procedure in this link worked. https://stackoverflow.com/questions/25766238/prematurely-exiting-a-loop-and-merge-block-in-qualtrics

Leave a Reply