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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Compose multiple if st...
Power Automate
Suggested Answer

Compose multiple if statement

(1) ShareShare
ReportReport
Posted on by 30
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
Categories:
I have the same question (0)
  • creativeopinion Profile Picture
    10,508 Moderator on at
    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!
  • Audrey2 Profile Picture
    30 on at
    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
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,969 Moderator on at
    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.
     
  • Suggested answer
    Ellis Karim Profile Picture
    11,994 Super User 2026 Season 1 on at
    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 605

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard