cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
0365
Level: Powered On

Multiple IF Statements in Microsoft Flow

I am using the following syntax for multiple if statements in Microsoft Flow. 


if(equals(outputs('Fields')['id'],'IEAB3W4AJUAAXPOQ'),'Classification',

if(equals(outputs('Fields')['id'],'IEAB3W4AJUAAXPPN'),'State',

if(equals(outputs('Fields')['id'],'IEAB3W4AJUAAXPOW','Category','Other'))

 

FYI - This code is inside a Compose and inside an Apply To Each. As it loops through, I am checking for the output value and comparing it with a string value. Basically, I need to verify the ID value and if the ID matches assign a display name such as Classification, State, Category and if the id does not match, then we use a display name of Other.

 

I would like to know if there is anything missing with this syntax multiple if statement? or if it is possible at all to do this with the outputs function? 

6 REPLIES 6
Super User
Super User

Re: Multiple IF Statements in Microsoft Flow

@0365:

 

While I haven't taken the time to check your logic ad syntax, it appears at first glace that using a switch statement might be a less complicated option for your to use.

 

Scott

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Community Support Team
Community Support Team

Re: Multiple IF Statements in Microsoft Flow

Hi @0365,

 

You said that the Compose is inside an Apply to each, I assume that you are getting a list of items first, then return a corresponding value to the item.

 

Please take the following code for a reference:

if(equals(items('Apply_to_each')?['Title'],'test1'),'classroom',if(equals(items('Apply_to_each')?['Title'],'test2'),'state','other'))

 

I am using the code to return value to each item in the list, and it works fine.

1.PNG2.PNG

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
0365
Level: Powered On

Re: Multiple IF Statements in Microsoft Flow

Thank you Mabel and Scott for your responses. 

 

 I figured out what is wrong with the code and below is the correct and working code. 

 

if(equals(outputs('Fields')['id'],'IEAB3W4AJUAAXPOQ'),'Classification',

if(equals(outputs('Fields')['id'],'IEAB3W4AJUAAXPPN'),'State',

if(equals(outputs('Fields')['id'],'IEAB3W4AJUAAXPOW','Category','Other')))

 

In summary, yes we can do multiple if statements in Flow and use equals to compare values. 

Administrator
Administrator

Re: Multiple IF Statements in Microsoft Flow

Hey, @0365!

Thank you for posting to the Flow Community Forum! It appears you have found a solution to your issue! If you feel as though your issue has been solved and you are satisfied with one of the previous replies, please click "Accept as Solution" on the reply that contains the solution so that this thread will be marked for other users to easily identify!

Thank you for being an active member of the Flow Community!

-Gabriel
Microsoft Flow Community Manager

-Gabriel
Microsoft Power Automate Community Manager
Are YOU a member of your local Power Automate User Group?
Fill out This Form to claim your Community User Group Member Badge!
Highlighted
nchambe
Level: Power Up

Re: Multiple IF Statements in Microsoft Flow

I've written about a new feature in Flow that would allow you to visually construct complex if/then statements using the condition control: https://sharepointlibrarian.com/2019/02/05/flow-now-supports-multiple-condition-controls-for-advance...

LisaChoi
Level: Powered On

Re: Multiple IF Statements in Microsoft Flow

So I am creating a workflow in Flow where I I need several statements to send email notifications to different users if condition equals x and if condition equals y.  

 

And "State" equal to "Delaware - DE"

  Or

      "State" equal to "Maryland - MD"

       "State" equal to "Pennsylvania - PA"

 

          Or

              "I am pleased with the overall quality of service " is equal to "Strongly Disagree"

               "I am pleased with the overall quality of service" is equal to "Disagree"

 

If no send email notification to user a

 

However, I need to create another statement that sends email notification to user b if "State" equals to "Arkansas - AR" 

Same logic as above but to different states.

 

Do I create this using a parallel branch or as a sequence or another step?

 

 

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,729)