Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Suggested answer

Compose multiple if statement

(1) ShareShare
ReportReport
Posted on by 28
Hello  y'all :)
 
So here is my issue, please help me!
I have a MS Form in which there is a question with multiple choices, which are :
- I prefer dark chocolate
- I prefer white chocolate
- I prefer milk chocolate
 
I would like, in power automate / in my flow to use Compose to allow me to change the wordings to :
- I prefer dark chocolate = would become = dark
- I prefer white chocolate = white
- I prefer milk chocolate = milk
 
 
I know that expression :
=If(equals(1,1), 'true', 'false')
 
First of, this expression doesn't work for me. Actually, it works up to this element :
=If(equals(1,1), 'true', 'false')
As soon as I add 'I prefer dark chocolate' I have the message error stating that my expression is not valid.
So I can go up to this point :
=if(equals(outputs('Obtenir_les_détails_de_la_réponse')?['body/r3a8ff7829721433fbc6d4ece6c0c533c'],1), 'yes', 'no')
 
But that's not really what I need. What I would like is to have something like this :
=if(equals(outputs('Obtenir_les_détails_de_la_réponse')?['body/r3a8ff7829721433fbc6d4ece6c0c533c'], 'I prefer dark chocolate'), 'dark', if(equals(outputs('Obtenir_les_détails_de_la_réponse')?['body/r3a8ff7829721433fbc6d4ece6c0c533c'], 'I prefer white chocolate'), 'white', if(equals(outputs('Obtenir_les_détails_de_la_réponse')?['body/r3a8ff7829721433fbc6d4ece6c0c533c'], 'I prefer milk chocolate'), 'milk')))
 
So a multiple if statement...
 
Is it possible ?
Is there a better way to do it ?
 
What do you think ?
 
 
Thank you !!!
Audrey
  • Suggested answer
    Ellis Karim Profile Picture
    11,092 Super User 2025 Season 1 on at
    Compose multiple if statement
    You can create a "lookup" table and then use the MS Forms question  "r3a8ff7829721433fbc6d4ece6c0c533c' to lookup and return the value: 
     
    {
      "I prefer dark chocolate": "dark",
      "I prefer white chocolate": "white",
      "I prefer milk chocolate": "milk"
    }
    
    For example, we can create the "lookup table" using a JSON object as shown below:
     
     
     
    We can then use an expression to perform the lookup, something like:
     
     variables('varLookUp')?[outputs('Obtenir_les_détails_de_la_réponse')?['body/r3a8ff7829721433fbc6d4ece6c0c533c']]
     
    In the example below, the value of the lookup is stored in a compose action:
     
     
    If  r3a8ff7829721433fbc6d4ece6c0c533c" contained  "I prefer white chocolate" we expect the lookup to return "white":
     
     
    Ellis
  • Suggested answer
    Michael E. Gernaey Profile Picture
    43,515 Super User 2025 Season 1 on at
    Compose multiple if statement
    Hi
     
    Add a variable at the top, call it whatever you want but make it a string.
     
    Another approach is simply to add a Switch
     
    The input to the switch would be the answer (the text) of your from you are showing above
     
    You would add 3 cases, in each case, place the string value you want to change
    So you would have these 3
    I prefer dark chocolate
    I prefer white chocolate
    I prefer milk chocolate
     
    Now inside each case, use the Set Variable, to change the words to whatever you want them to be based on the Case they are in
     
    now use that variable to populate whatever data you want in the back end or email etc.
     
  • Audrey2 Profile Picture
    28 on at
    Compose multiple if statement
    Hello !
     
    Unfortunatly at work I don't have access to youtube :(
     
    I'm trying again my luck with a If statement. 
    Here is the result : 
    =if(equals(outputs('Obtenir_les_détails_de_la_réponse')?['body/r3a8ff7829721433fbc6d4ece6c0c533c'], '1'),'1',if(equals(outputs('Obtenir_les_détails_de_la_réponse')?['body/r3a8ff7829721433fbc6d4ece6c0c533c'],'test2'),'state','other'))
     
    However, as soon as I change what's in yellow to 'I prefer dark chocolate' it doesn't work and states that the expression is invalid. 
    Would you know why?
     
     
    Kindly, 
    Audrey
  • creativeopinion Profile Picture
    10,439 Super User 2025 Season 1 on at
    Compose multiple if statement
    Instead of using an if() statement you can create a dynamic output based on a selection made in your form. Reference this section of my YT Tutorial linked below. 
     
    If you still run into issues, upload a screenshot of where you are stuck! Ensure you've toggled off the new designer and click each action to expand it.
     
    In this Microsoft Power Automate Tutorial I’m going to cover where file uploads from your Microsoft Forms are saved. I’ll also show you how attach the uploaded files to an email and how to dynamically name the files and customize the recipient of the email based on the selections made in your Microsoft Form. I will also cover how to handle responses that don’t include any file uploads.
     
    Hope this helps!

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492