Skip to main content
Community site session details

Community site session details

Session Id : kH4QkwxuvlMg4d2PzcpXoM
Power Automate - Building Flows
Unanswered

MS Form w/3 Choices>Power Automate>Email

Like (0) ShareShare
ReportReport
Posted on 27 May 2022 18:41:53 by 2

Hi,

I have a MS Form where each question has 3 possible answers, "pass" "fail" "n/a." I would like for the result to have three possibilities resulting in two different emails:

 

1. "Pass" is selected for every question-> Email is sent to group #1

2. A combination of "Pass" and/or "N/A" is selected> Email Sent to group #1

3. "Fail" is selected for any question: Email sent to Group #2.

 

Currently my results are that if "pass" is selected for every question it emails group #1. If, "N/A" or "Fail"is selected, it goes to Group #1. I am struggling to figure out my conditioning. I have two conditions, seen below.

 

budd5582_0-1653676880219.png

 

I would appreciate any help 

  • eliotcole Profile Picture
    4,266 Moderator on 30 May 2022 at 09:39:49
    Re: MS Form w/3 Choices>Power Automate>Email

    Hi, @budd5582, if you don't care what the questions are, then you can get the responses to all your questions using some xml and a select. 

    Solution With xml(), xpath(), and Select

    Create Two Constants From The Form Response

    formatXmlRootCNST

    This one is to make a JSON representation of an XML structure, so that the system can understand it when it converts it to XML.

    1.jpg
    {
     "root": @{body('Get_response_details')}
    }

    You can just paste this directly into your compose if you use it, as long as your Get response details is named the same. If you wish to build yours manually, omit the '@{body('Get_response_details')}' part, and select it from your form.

    xpathArrayCNST

    This changes the JSON you made into XML data, then uses the xpath() function to make a special array out of each entry:

    2.jpg
    xpath(
     xml(
     outputs('formatXmlRootCNST')
     ),
     '//*'
    )

     

    Select

    This is the main game, and as mentioned previously:

    3.jpg

     

    From
    range(
     0,
     length(
     outputs('xpathArrayCNST')
     )
    )
    Map
    xpath(
     outputs('xpathArrayCNST')[item()], 
     'string(//*)'
    )​

    This now gives you an array of all the answer, with this you can do what you wish.

     

    Ongoing?

    If I were to hazard a guess at the ongoing logic? I would say a Switch action would be your best bet, and use some of the following to get there.

     

    answersCountCNST

    This counts the amount of answers, and removes one, since it's just a summation of everything at the start.

    min(
     length(
     body('Select')
     ),
     1
    )

     

    Filter Each Answer

    This will gather all answers that are the string 'Pass':

    From
    @body('Select')
    Advanced
    @equals(item(), 'Pass')

    It's important to note that this is just for the string 'Pass', if you've used choices, that data may be represented differently, so you will need to see what a response with Pass looks like, and for 'n/a', and for 'Fail', then use that here.

     

    The Rest

    Make a filter for each choice, and then you can easily make logic to create a switch based on the results therein.

     

    The key here is to get that array of answers, you can do more with that than what you have.

  • budd5582 Profile Picture
    2 on 29 May 2022 at 10:53:45
    Re: MS Form w/3 Choices>Power Automate>Email

    Thank you so much for the detailed response. I'm wondering - do you know of an alternate way for a Form that has almost 40 questions? 

  • vivekpande18 Profile Picture
    894 Super User 2024 Season 1 on 28 May 2022 at 08:31:21
    Re: MS Form w/3 Choices>Power Automate>Email

    Hi @budd5582 ,

     

    You don't require to add multiple conditions action. Find below the steps to know more.

     

    In my case, all my question responses are stored in Compose action.

     

    vivekpande18_0-1653725853228.png

     

    Now evaluating all the question to check the output.

    1- For question 1

    vivekpande18_1-1653725989995.png

    Inputs:  or(

                        equals(outputs('Question_1'),'Pass')

                        equals(outputs('Question_1'),'NA')

                    )

    simple explanation: 

    question 1 == Pass OR

    question 1 == NA

    output will be true if result is either pass or NA else false

     

    2- For question 2 & 3

    vivekpande18_2-1653726361107.png

    Inputs :

    or(equals(outputs('Question_2'),'Pass'),equals(outputs('Question_2'),'NA'))

    or(equals(outputs('Question_3'),'Pass'),equals(outputs('Question_3'),'NA'))

     

    Condition:

    vivekpande18_3-1653726532260.png

    Outputs of above compose action which contains expression

    Yes:

    Send email to group 2

    No:

    Send email to group 1

     

    Thanks

    Vivek Pande

     

    If this post helps answer your question, please "Accept as Solution" to help others find it more quickly.

    If you thought this post was helpful, please give it a Thumbs Up.


    Subscribe to my YouTube channel to get more interesting content on Power Automate.

     

     

     

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

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!