web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to set up Power Au...
Power Automate
Unanswered

How to set up Power Automate with every combination of 5 conditions

(0) ShareShare
ReportReport
Posted on by 6

I have a survey with 5 different yes/no questions. If they answer yes to any question, more questions will appear. I want to create a flow that sends an email to the survey responder with all of the questions and answers they responded to (but none of the questions they didn't respond to if they didn't select "yes").

 

The 5 questions are not dependent on each other so there can be any combination of the 5 yes/no questions. I started creating Conditions in my flow but soon realized that there are a possible 120 combinations of these 5 yes/no responses! I'm wondering if there is an easier, softer way to do this. Any help is greatly appreciated!

Categories:
I have the same question (0)
  • vivekpande18 Profile Picture
    894 Super User 2024 Season 1 on at

    Hi @Sara_E , 

    Can you tell us more about it. 

    From which form you are grabbing those questions. 

     

    What are you actually trying to achieve. 

     

    Thanks

    Vivek

  • VictorIvanidze Profile Picture
    13,073 on at

    Sorry I do not understand the problem. Let's suppose you have 5 string variables strAnswer1,...strAnswer5 that contain the answers. You have to compare each variable with "yes".  5 comparisons.  Why do you think about 120 combinations (in fact you have only 2^5=32 )?

  • Sara_E Profile Picture
    6 on at

    I could be doing the math wrong! I for some reason thought maybe it was a factorial (5!). Anyway, each of these five questions can have a yes or no response. I need every unique combination of all five questions being answered. Example:

     

    First combination:

    Question 1: Yes

    Question 2: No

    Question 3: No

    Question 4: No

    Question 5: No

     

    Second combination:

    Question 1: Yes

    Question 2: Yes

    Question 3: No

    Question 4: No

    Question 5: No

     

    Third combination:

     

    Q1: Yes

    Q2: Yes

    Q3: Yes

    Q4: No

    Q5: No

     

    ... and so on.

     

    Depending on the combination, I want to send an email that is specific to that combination. Maybe it's 32 and not 120 (not great with math!), but even so I don't want to have to do 32 different conditions in my flow, so I'm hoping there's an easier solution?

  • Sara_E Profile Picture
    6 on at

    I'm pulling from Survey123. And I would like to send a unique email out for each unique combination of the 5 questions. 

  • VictorIvanidze Profile Picture
    13,073 on at

    1) Initialize the array ArrAnswers (5 elements):

     

     

    [0,0,0,0,0]

     

     

     

    2) Initialize the array ArrEmailBodies (32 elements):

     

     

    ["Email body 0","Email body 1",..."Email body 31"]

     

     

     

    3)

    If Q1=Yes then set ArrAnswers[0]=1

    If Q2=Yes then set ArrAnswers[1]=1

    If Q3=Yes then set ArrAnswers[2]=1

    If Q4=Yes then set ArrAnswers[3]=1

    If Q5=Yes then set ArrAnswers[4]=1

     

    4) Initialize an integer variable intIndex with the following expression:

     

     

    add(mul(variables('ArrAnswers')[0],16),add(mul(variables('ArrAnswers')[1],8),add(mul(variables('ArrAnswers')[2],4),add(mul(variables('ArrAnswers')[3],2),variables('ArrAnswers')[4]))))

     

     

     

    VictorIvanidze_0-1652817261346.png

     

    5) now to get the proper email body use the following:

     

     

    ArrEmailBodies[variables('intIndex')]

     

     

     

    VictorIvanidze_2-1652817383062.png

     

  • Sara_E Profile Picture
    6 on at

    Thank you so much for your help! Okay so I have the following:

     

    1. I put 0,0,0,0,0 - is that correct? Or should I put "yes", "no" - since those are actually the only two answers that are allowed for each question?

    Sara_E_0-1652877975786.png

     

    2. For now the "Email body 0, Email body 1, etc." are just placeholders until I put the actual emails in there - which will come later.

    Sara_E_1-1652878001257.png

     

    3. So this is where I get stuck. I'm using conditions to do what you suggested. I can put if the Q1 is equal to Yes then set a ArrAnswers to equal 1.

     

    Sara_E_3-1652879896231.png

     

     

    But when I test my flow I get the following error. Any thoughts on how I can fix this? Thank you!

     

    Sara_E_2-1652879869446.png

     

  • VictorIvanidze Profile Picture
    13,073 on at

    Please test this mdified flow.

     

    Combination5answers1.pngCombination5answers2.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard