Workflow: how to add condition "at least X of the following Y options" | XM Community

Workflow: how to add condition "at least X of the following Y options"

  • 14 December 2022
  • 6 replies
  • 164 views

Userlevel 1
Badge +2

Hello,
I want to trigger an event based workflow, but my only options while adding conditions are "all of the following are true" and "any of the following are true."
I need an option that allows me add a condition in this way: "at least X of the following are true." For example, I have 10 questions (Yes/No) in my survey. And I want to trigger this workflow when a participant answers to at least 2 of those questions "Yes."
Without this option, I have to add the each answer combination as an alternative condition which is extremely time consuming for long surveys. (like, (Q1 AND Q2) OR (Q1 AND Q3) OR (Q1 AND Q4) etc etc)
Any suggestions? Thank you!


6 replies

Userlevel 6
Badge +33

Merve You could add an embedded data field to your survey flow that would be your send/don't send trigger.
Creating the logic in the survey flow would be less complicated than within the workflow. What type of questions are the ten yes/no questions? Mult. Choice? Matrix Table?

Userlevel 1
Badge +2

jmborzick Thank you so much for the response. I oversimplified by saying Y/N, essentially some questions are multiple choice and some are open text entry with numbers only, so it needs to trigger if it is e.g. above a certain number (or between two numbers). I have 6 statements that at least 3 of them needs to be true which makes 20 possible combinations. And those statements consists of multiple questions from my survey. For example:
Statement 1: (Q93 Yes) OR (Q101 above 10) OR (Q128: choice A) ...
2: (Q94 Yes) OR (Q108: chice C) OR ...
...
6: ...

So ( 1 AND 2 AND 3) OR (1 AND 2 AND 4) OR ... -> 20 combinations
Imagine doing this on workflow with "all of the following" and "any of the following" options only! Which I did before for another workflow, but it took too much time. I'll give a try to apply your solution and create logic in the survey. But if there is a way to add this function "At least X of the following are true" to workflow (e.g. as Java Script) that would be the most practical. Do you know a way to do that?



Userlevel 6
Badge +33

Merve Here's an option.
At the start of the survey, add an embedded data field for each of your six questions with each value being zero (Q1=0,Q2=0, Q3=0, etc)
For each question, add branch logic. The branch would read, "IF Q1 (statement meets condition) then set embedded data field Q1=1" IF Q2 (Statement meets condition) then set embedded data field Q2=1", etc.
After the branches, set an embedded data field "Question Sum." The value would be: $e{ e://Field/Q1 + e://Field/Q2 + e://Field/Q3 + e://Field/Q4 + e://Field/Q5 + e://Field/Q6 }
Your logic in your workflow would then include the condition IF "Question Sum" is greater than or equal to 3 "

Userlevel 1
Badge +2

jmborzick Thank you so much, I understood what you are describing and will definitely keep this method in mind for future problems. For this one, there is no such thing as "6 questions." There are 6 statements that consists of multiple, way more questions. That is, e.g. the first statement is (Q93 Yes) OR (Q104 above 10) OR (Q119 etc etc) OR (Q126) OR (Q130) OR Q(133) -> it consists of these questions, and at least one of those questions being true makes statement 1 true. There are 6 statements like this, and at least 3 of them should be true. Statement 2 only consists of Q134. I wrote a logic set below. For simplification, I just wrote the number of the question without its answer needed (e.g. just Q93, instead of Q93: Yes)
I hope that clarifies my problem. Thank you!
Screenshot 2022-12-16 at 11.32.46 PM.png


Userlevel 6
Badge +33

Merve Based on what you wrote, I'd set it up the same way. I'd have branch logic set for #1 based on all of your "Or" statements and if that is TRUE, I'd set the embedded data field as a "1." I'd then repeat for each of your other logic sets.

Userlevel 1
Badge +2

Thank you jmborzick

Leave a Reply