cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Multiple Flow Conditions

Is it possible to have multiple conditions in one Flow? For example, I would like X to happen when Y= 2 and Z =0 (two conditions).

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

I think there is a better way than what Mona suggested. You can use a condition to do both at once. The syntax is something like this:

 

@and(contains(body('Get_file_metadata')?['Path'], 'Submit to Manager'),equals(triggerBody()?['Modified'], triggerBody()?['Created']))

 

This is what I'm using in a Flow to do something when the Path (from Metadata) contains 'Submit to Manager' AND when Modified = Created.

 

The easiest way I've found is to enter in one of the conditions you need in the basic mode:

1.PNG

 

 

Then click edit in advanced, and copy the string:

2.PNG

 

 

Then do the same for your second, (and 3rd, 4th, etc.) conditions:

3.PNG

4.PNG

 

 

Then put the strings together like so:

For an AND statement -

@and("String 1 without the '@'","String 2 without the '@'")

becomes: @and(contains(body('Get_file_metadata')?['Path'], 'Submit to Manager'),equals(triggerBody()?['Modified'], triggerBody()?['Created']))

 

If you want it to be an OR statement, simply change the @and to @or

 

Hope this helps!

View solution in original post

18 REPLIES 18
Community Support
Community Support

Hi LP,

 

It is possible and easy to achieve. You can either use it like this:

 1.PNG

 

In addition, Flow supports nested conditionals, which make it possible to have very advanced branching logic. Switch case makes it very easy to have parallel branches of conditional logic based on a single value.

0.png

You can find switch by selecting the More ... option after selecting New Step and then choosing Add a Switch Case. Inside a Switch Case you will select a value from the trigger or a previous step to switch on. For example, if you use this template for a SharePoint approval flow, the switch is on the option the approver selects in the approval email. 

 

 

Let me know if this meets your requirement.

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Mona, what about a multiple OR condition, like if A==1 or B==2?

Anonymous
Not applicable

I think there is a better way than what Mona suggested. You can use a condition to do both at once. The syntax is something like this:

 

@and(contains(body('Get_file_metadata')?['Path'], 'Submit to Manager'),equals(triggerBody()?['Modified'], triggerBody()?['Created']))

 

This is what I'm using in a Flow to do something when the Path (from Metadata) contains 'Submit to Manager' AND when Modified = Created.

 

The easiest way I've found is to enter in one of the conditions you need in the basic mode:

1.PNG

 

 

Then click edit in advanced, and copy the string:

2.PNG

 

 

Then do the same for your second, (and 3rd, 4th, etc.) conditions:

3.PNG

4.PNG

 

 

Then put the strings together like so:

For an AND statement -

@and("String 1 without the '@'","String 2 without the '@'")

becomes: @and(contains(body('Get_file_metadata')?['Path'], 'Submit to Manager'),equals(triggerBody()?['Modified'], triggerBody()?['Created']))

 

If you want it to be an OR statement, simply change the @and to @or

 

Hope this helps!

Anonymous
Not applicable

I think there is a better way than what Mona suggested. You can use a condition to do both at once. The syntax is something like this:

 

@and(contains(body('Get_file_metadata')?['Path'], 'Submit to Manager'),equals(triggerBody()?['Modified'], triggerBody()?['Created']))

 

This is what I'm using in a Flow to do something when the Path (from Metadata) contains 'Submit to Manager' AND when Modified = Created.

 

The easiest way I've found is to enter in one of the conditions you need in the basic mode:

1.PNG

 

 

Then click edit in advanced, and copy the string:

2.PNG

 

 

Then do the same for your second, (and 3rd, 4th, etc.) conditions:

3.PNG

4.PNG

 

 

Then put the strings together like so:

For an AND statement -

@and("String 1 without the '@'","String 2 without the '@'")

becomes: @and(contains(body('Get_file_metadata')?['Path'], 'Submit to Manager'),equals(triggerBody()?['Modified'], triggerBody()?['Created']))

 

If you want it to be an OR statement, simply change the @and to @or

 

Hope this helps!

View solution in original post

Hello everyone,

Be so kind and help me, I cant figure out how to adapt your example to my situation.

I attached an example of what i should do. A simple excel file with a simple set of rules 🙂 but isnt so simple when i try to insert them into a flow.

For example, if my client debt is between 75000 and 150000 and the overdue is, lets say, 83 days, approval should go to the 6th option.

Also if i need to unblock a client for 2 months, flow condition should go to case 5 or 6, depending on the debt value and overdue. For unblocking for more than 3 months, the approval should choose case 8 or 9.

Any idea? Thats even possible? 🙂

 

And if flow cant do that, maybe if i keep just the debt and overdue cases, it is possible?

Thanks alot!!
Approvals.JPG

Interesting, but this solution makes it hard for business users to maintain the complex WDL syntax.  I prefer Mona's solution because it retains the simple GUI editor for Flow 

Thanks Mona for the switch case idea. 

Switch Case is a good Idea but when the options in a list column(choice type for example) increases (more than 20 )than the GUI also becomes very tough to maintain....including all scrolling. Just a Suggestion.

is there an easy means to look for multipe "or" options within one field?

 

like for example using the data that has been used in this thread.

Lets say that I'm looking at "path" and need a condition that helps me look for 4 or more possibilities that I want to take the same action on. 

 

if path contain= Submit to manager OR Pending Manager OR NYC OR San Fran

 

Of course I can do it with a switch case, but my flow gets extremely wide in my window and def can see how down the road this extra bulk will just complicate things.

 

thank you!!

Thanks for great suggestion. However in my case its seems to be nor working. Following is my condition i am using 

@and(@not(equals(triggerBody()?['{FilenameWithExtension}'], triggerBody()?['{Name}'])) , @not(contains(triggerBody()?['Author']?['Claims'], 'dynadme@adobe.com')))

 a

I am getting error as -

The template validation failed: 'The template action 'Condition' at line '1' and column '1739' is not valid: "The template language expression 'and(@not(equals(triggerBody()?['{FilenameWithExtension}'], triggerBody()?['{Name}'])) , @not(contains(triggerBody()?['Author']?['Claims'], 'dynadme@adobe.com')))' is not valid: the string character '@' at position '4' is not expected.".'.

I found the solution for my problem, following string worked for me. Basically I removed @ from @not

 

@and(not(equals(triggerBody()?['{FilenameWithExtension}'], triggerBody()?['{Name}'])) , not(contains(triggerBody()?['Author']?['Claims'], 'dynadme@adobe.com')))

New Member

I have a custom list where i have Two columns as Start date and end date. User will be selecting future dates. For example if user selects Start date as 01/20/2019 and end date as 01/25/2019, i need to run a Recurrence flow to update a custom list column to compare todays date and if the the selected start date and end date are with in the range. I need to add two conditons to compare start date and end date, i was able to add only one condition 

Condition.PNG

Can we add two conditions as

@and(greaterOrEquals(utcNow(), items('Apply_to_each')?['StartDate']),lessOrEquals(utcNow(), items('Apply_to_each')?['EndDate']))

and compare start and end date.

 

Thanks

New Member

dear all,

I am a new user of Microsoft flow and honestly not really a black belt software guy 🙂 I kindly ask your help to solve I believe a simple issue. I would like to save some email attachments in two separate Sharepoint folders depending on attachments. all the flows model I have seen consider only the "flagged" option but for what I have understood it is not possible to have two different type of flags. So if a flag an email, all the attchments would go in the same folder. question is: is there a way to make different type of flags or to allow with a manual action (flagging or similar) to distinguish what has to go in one folder and what in the other one ? thnaks a lot for your attention. Mauro

Regular Visitor

Flow has now improved their condition control to allow more complex nested if/then statements and such using the visual builder. I wrote about it here: https://sharepointlibrarian.com/2019/02/05/flow-now-supports-multiple-condition-controls-for-advance...chrome_5ungBioTo9.png

 

 

Does this work for more than 2 conditions?

@chandrashekharis correct. Having to use switch case with scrolling sucks -- too cumbersome for more than 3 cases.

 

Why not just use the same structure as "AND/OR" and add a "CASE" choice and have the switch criteria drop down?

switch is the answer.

 

As you pointed out, the GUI growing horizontally makes working with it difficult.

I had a slightly different problem - Filter Array - but this post drew me to the bit about not having the @symbols in the parameters of the @And. This has solved a problem that had me shouting at the monitor! Thanks!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (7,325)