Use expressions in conditions in Power Automate - Power Automate (2023)

  • Article
  • 7 minutes to read

In this tutorial, you'll learn to use expressions and conditions to compare multiple values in Advanced mode.

When you create a cloud flow, you can use the Condition card in basic mode to quickly compare a single value with another value. However, there're times when you need to compare multiple values. For example, you might want to check the value of a few columns in a spreadsheet or database table.

You can use any combination of the following logical expressions in your conditions.

ExpressionDescriptionExample
andTakes two arguments and returns true if both values are true.
Note: Both arguments must be Booleans.
This expression returns false:
and(greater(1,10),equals(0,0))
orTakes two arguments and returns true if either argument is true.
Note: Both arguments must be Booleans.
This expression returns true:
or(greater(1,10),equals(0,0))
equalsReturns true if two values are equal.For example, if parameter1 is someValue, this expression returns true:
equals(parameters('parameter1'), 'someValue')
lessTakes two arguments and returns true if the first argument is less than the second argument.
Note: The supported types are integer, float, and string.
This expression returns true:
less(10,100)
lessOrEqualsTakes two arguments and returns true if the first argument is less than or equal to the second argument.
Note: The supported types are integer, float, and string.
This expression returns true:
lessOrEquals(10,10)
greaterTakes two arguments and returns true if the first argument is greater than the second argument.
Note: The supported types are integer, float, and string.
This expression returns false:
greater(10,10)
greaterOrEqualsTakes two arguments and returns true if the first argument is greater than or equal to the second argument.
Note: The supported types are integer, float, and string.
This expression returns false:
greaterOrEquals(10,100)
emptyReturns true if the object, array, or string is empty.This expression returns true:
empty('')
notReturns the opposite of a boolean value.This expression returns true:
not(contains('200 Success','Fail'))
ifReturns a specific value if the expression results in true or false.This expression returns "yes":
if(equals(1, 1), 'yes', 'no')

Prerequisites

Here's what you'll need to complete this walkthrough.

  • Access to Power Automate.
  • Your own spreadsheet with the tables described later in this walkthrough. Be sure to save your spreadsheet in a location such as Dropbox or Microsoft OneDrive so that Power Automate can access it.
  • Microsoft 365 Outlook (While we use Outlook here, you can use any supported email service in your flows.)

Use the 'or' expression

Sometimes your workflow needs to take an action if the value of an item is valueA or valueB. For example, you may be tracking the status of tasks in a spreadsheet table. Assume that the table has a column named Status and the possible values in this column are:

  • completed
  • blocked
  • unnecessary
  • not started

Here's an example of what the spreadsheet might look like:

Use expressions in conditions in Power Automate - Power Automate (1)

Given the preceding spreadsheet, you want to use Power Automate to remove all rows with a Status column that's set to completed or unnecessary.

Let's create the flow.

Start with a blank flow

  1. Sign into Power Automate.

  2. On the left pane, select My flows.

    Use expressions in conditions in Power Automate - Power Automate (2)

  3. Select New flow > Scheduled cloud flow.

    Use expressions in conditions in Power Automate - Power Automate (3)

Add a trigger to your flow

  1. Give your flow a name.

    (Video) Power Automate flow Expressions Tutorial

  2. Set the schedule to run the flow once daily.

  3. Select the Create button to go to the next step.

    Use expressions in conditions in Power Automate - Power Automate (4)

Select the spreadsheet and get all rows

  1. Select New step.

    Use expressions in conditions in Power Automate - Power Automate (5)

  2. Search for rows, and then select Excel Online (Business).

    Note

    Select the "get a row" action that corresponds to the spreadsheet that you're using. For example, if you're using Google Sheets, select Google Sheets - Get rows.

  3. Select the List rows present in a table action.

    Use expressions in conditions in Power Automate - Power Automate (6)

  4. Select the Location, Document Library, File, and Table that contain your data.

    Use expressions in conditions in Power Automate - Power Automate (7)

Check the status column of each row

  1. Select New step.

  2. Search for apply to each, and then select the Apply to each - Control.

    Use expressions in conditions in Power Automate - Power Automate (8)

  3. Add the value token to the Select an output from previous steps box.

    (Video) Power Automate - Multiple IF expressions

    This value token represents the spreadsheet table and all of its data.

    Use expressions in conditions in Power Automate - Power Automate (9)

  4. Select Add an action on the Apply to each card.

    Use expressions in conditions in Power Automate - Power Automate (10)

  5. Search for condition, and then select the Condition control.

  6. Add the following Or expression. This Or expression checks the value of each row in the table. If the value of the Status column is completed Or unnecessary, the Or expression evaluates to "true".

    Here's an example of a Condition card.

    Use expressions in conditions in Power Automate - Power Automate (11)

Delete matching rows from the spreadsheet

  1. Select Add an action on the If yes branch of the condition.

    The If yes branch runs if the Or condition evaluates to true.

  2. Search for Delete a row, select Excel Online (Business), and then select Delete a row.

    Use expressions in conditions in Power Automate - Power Automate (12)

  3. On the Delete a row card, set the Location, Document Library, File, and Table boxes exactly as you set these boxes on the List rows present in a table card earlier in this tutorial.

  4. In the Key Column dropdown list, select _PowerAppsId_.

  5. In the Key Value field, insert the _PowerAppsId_ dynamic value.

    Use expressions in conditions in Power Automate - Power Automate (13)

  6. Save your flow.

    (Video) Power Automate Tutorial - How to use conditions

Run the flow with the 'or' expression

The flow runs after you save it. If you created the spreadsheet shown earlier in this tutorial, here's what it looks like after the run completes.

Use expressions in conditions in Power Automate - Power Automate (14)

Notice all data from rows that had completed or unnecessary in the Status column were deleted.

Use the 'and' expression

Assume you have a spreadsheet table with two columns. The column names are Status and Assigned. Assume also that you want to delete all rows if the Status column's value is blocked and the Assigned column's value is John Wonder. To accomplish this task, follow all steps earlier in this tutorial, but when you edit the Condition card in advanced mode, use the and expression shown here.

@and(equals(item()?['Status'], 'blocked'), equals(item()?['Assigned'], 'John Wonder'))

Here's an example of a Condition card.

Use expressions in conditions in Power Automate - Power Automate (15)

Run the flow with the 'and' expression

If you've followed the steps in this tutorial, your spreadsheet should look similar to the following screenshot.

Use expressions in conditions in Power Automate - Power Automate (16)

After your flow runs, your spreadsheet should look similar to the following screenshot.

Use expressions in conditions in Power Automate - Power Automate (17)

Use the 'empty' expression

Notice that there are several empty rows in the spreadsheet now. To remove them, use the empty expression to identify all rows that don't have text in the Assigned and Status columns.

To accomplish this task, follow all steps listed in the Use the 'and' expression section earlier in this tutorial. When you edit the Condition card in advanced mode, use the following empty expression.

@and(empty(item()?['Status']), empty(item()?['Assigned']))

Your Condition card should look similar to the following screenshot.

Use expressions in conditions in Power Automate - Power Automate (18)

After your flow runs, the spreadsheet should look similar to the following screenshot.

(Video) If Expression in Power Automate

Use expressions in conditions in Power Automate - Power Automate (19)

Notice extra lines are removed from the table.

Use the 'greater' expression

Imagine you've bought baseball tickets for your coworkers and you're using a spreadsheet to ensure you're reimbursed by each person. You can quickly create a cloud flow that sends a daily email to each person who hasn't paid the full amount.

Use the greater expression to identify the employees who haven't paid the full amount. You can then automatically send a reminder email to those who haven't paid in full.

Here's a view of the spreadsheet.

Use expressions in conditions in Power Automate - Power Automate (20)

Here's the implementation of the greater expression that identifies all persons who have paid less than the amount due from them.

@greater(item()?['Due'], item()?['Paid'])

Use the 'less' expression

Imagine you've bought baseball tickets for your coworkers, and you're using a spreadsheet to ensure you're reimbursed by each person by the date to which everyone agreed. You can create a cloud flow that sends a reminder email to each person who hasn't paid the full amount if the current date is less than one day before the due date.

Use the and expression with the less expression since there are two conditions being validated.

Condition to validateExpression to useExample
Has the full amount due been paid?greater@greater(item()?['Due'], item()?['Paid'])
Is the due date less than one day away?less@less(item()?['DueDate'], addDays(utcNow(),1))

Combine the 'greater' and 'less' expressions in an 'and' expression

Use the greater expression to identify the employees who have paid less than the full amount due and use the less expression to determine if the payment due date is less than one day away from the current date. You can then use the Send an email action to send reminder emails to those employees who haven't paid in full and the due date is less than one day away.

Here's a view of the spreadsheet table.

Use expressions in conditions in Power Automate - Power Automate (21)

Here's the implementation of the and expression that identifies all employees who have paid less than the amount due from them and the due date is less than one day away from the current date.

@and(greater(item()?['Due'], item()?['Paid']), less(item()?['dueDate'], addDays(utcNow(),1)))

Use functions in expressions

Some expressions get their values from runtime actions that might not yet exist when a cloud flow starts to run. To reference or work with these values in expressions, you can use functions that the Workflow Definition Language provides. More information. To learn more, go to Reference guide to workflow expression functions in Azure Logic Apps and Power Automate.

FAQs

How do you use condition in Power Automate flow? ›

Select Edit. Under the last action, select New step > Condition.
...
Add a condition
  1. Sign into Power Automate.
  2. On the left pane, select My flows.
  3. On the list of flows, select the flow you want to edit by placing a check mark in the circle and then selecting More commands (the three dots).
Dec 15, 2022

How do you use multiple conditions in Power Automate? ›

Power Automate condition contains multiple values
  1. On Power Automate, go to + Create > Instant cloud flow > Select the trigger 'Manually trigger a flow' > Create.
  2. Next, add an action to get the items from the list. Click on +New step > Get items. ...
  3. To add the multiple conditions, add a condition control.
Apr 21, 2022

Can you use dynamic content in expression Power Automate? ›

This makes it possible to clearly see your expressions as you type them out in Power Automate. As you type it out, you can even switch to the dynamic values tab to insert them in your expression just by clicking on it.

Can we set variable in condition in Power Automate? ›

Power automate initialize variable vs set variable

But in the Set variable, we will use the variable which we have initialized and set the value. But set variables can be used local level, which means we can set the variable with the value in the condition, loop, and scope.

How many conditions can you have in a Power Automate flow? ›

There is a limit of 8 nested conditions (as of the writing of this post).

How do you check if a condition is in Power Automate? ›

Example-2: Using IF(condition) action

After triggering the flow manually, search for Condition under control action. Then add this action to our flow. Then insert the value to check and their IF yes & IF no values like below. This is how to use the If-Condition action in power Automate.

What language is Power Automate expressions? ›

"Microsoft Power Fx is a low-code general purpose programming language based on spreadsheet-like formulas. It is a strongly typed, declarative, and functional language, with imperative logic and state management available as needed.

How do you handle multiple if conditions? ›

To use multiple IF functions where we can add multiple logical tests, after the first logical condition and TRUE value, insert another IF Function followed by the different logical values to be compared with the TRUE value result.

Can you have multiple conditions in one if statement? ›

The multiple IF conditions in Excel are IF statements contained within another IF statement. They are used to test multiple conditions simultaneously and return distinct values. The additional IF statements can be included in the “value if true” and “value if false” arguments of a standard IF formula.

How many conditions can be used in and/or functions *? ›

Naturally, you are not limited to using only two AND/OR functions in your IF formulas. You can use as many of them as your business logic requires, provided that: In Excel 2007 and higher, you have no more than 255 arguments, and the total length of the IF formula does not exceed 8,192 characters.

How do you reference variables in expression Power Automate? ›

To work with variables, we need first add Variables() to get the Variable output, then within the brackets we need to take use of single quotes to quote the variable name.

What are three easy ways to use dynamic content? ›

Three easy ways to use dynamic content
  1. Dynamic content based on demographics. A great way to begin engaging your audience in more meaningful ways is to send messages based on basic demographic info. ...
  2. Dynamic content based on preferences. ...
  3. Dynamic content based on email data.

What are some advanced ways to use dynamic content? ›

Different Ways to Present Dynamic Content
  • Newsletters and Emails. Both newsletters and emails are probably the most basic and classic forms of dynamic content being presented. ...
  • Landing Pages. ...
  • Articles. ...
  • Forms and Purchases. ...
  • Product Pages. ...
  • Website Ads. ...
  • Understand Your Customer and Users First. ...
  • Use Data to Monitor Your Content.

What operations can you use on condition variables? ›

Condition Variable Operations: Wait and Signal

Because the calling thread is the only thread that is running in the monitor, it "owns" the monitor lock. When it is put into the waiting queue of a condition variable, the system will automatically take the monitor lock back.

How many nested conditions can you have in Power Automate? ›

The limit for nesting is 8. You can solve this by either combining conditions. Use expressions instead of condition actions.

Why would you include run after conditions on an action in Power Automate? ›

That's the “Run After” capability. This feature allows you to automate a certain action to occur only if another action develops in a certain way.

How do I add if condition in flow design? ›

Adding and configuring conditional statements
  1. At the stage in the flow where you want to define some conditional logic, click the (+), go to the Toolbox tab, and then click If (conditional). ...
  2. Configure the first if branch by defining one or more If conditions, and the actions to perform if these conditions are true:

How do you write a trigger condition in Power Automate? ›

On Power Automate, create an automated flow that will trigger when an item is created or modified. Provide the SharePoint site address and the list name. On that trigger, go to the setting > trigger conditions. Insert the below expression to check whether the title contains 'Power BI' or not.

How do you check condition in Power Automate? ›

After triggering the flow manually, search for Condition under control action. Then add this action to our flow. Then insert the value to check and their IF yes & IF no values like below. This is how to use the If-Condition action in power Automate.

How do I apply a condition in power query? ›

Add a conditional column (Power Query)
  1. To open a query, locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query > Edit. ...
  2. Select Add Column > Conditional Column. ...
  3. In the New column name box, enter a unique name for your new conditional column.

How do you add three conditions to an IF statement? ›

You can use the following formulas to create an IF function with 3 conditions in Excel:
  1. Method 1: Nested IF Function =IF(C2<15, "Bad", IF(C2<20, "OK", IF(C2<25, "Good", "Great")))
  2. Method 2: IF Function with AND Logic =IF(AND(A2="Mavs", B2="Guard", C2>25), "Yes", "No")
Jul 24, 2022

How do you write if condition inside if condition? ›

Recap of If Else Statements

If the condition inside if is true, the statements inside the if bracket is executed. If the condition turns out to be false, the if block is skipped, and the statements inside the else block are executed. For example, given a number we need to check if it is even or not.

How do you write multiple if conditions in one line? ›

To put an if-then-else statement in one line, use Python's ternary operator x if c else y . This returns the result of expression x if the Boolean condition c evaluates to True . Otherwise, the ternary operator returns the alternative expression y .

Videos

1. ETH Global Lecture Series: The Nobel Turing Challenge – Creating the Engine for Scientific Discovery
(ETH Zürich)
2. Power Automate - Expressions and Dynamic Values inside a loop
(abm)
3. Power Automate Tutorial - Expressions 101
(Jon Levesque)
4. Power Automate Actions - Condition (React to Data!)
(Flow Joe)
5. Power Automate flow Trigger Conditions
(Reza Dorrani)
6. Trigger Conditions in Power Automate - prevent unnecessary flow runs #PowerAutomate #TipsAndTricks
(DamoBird365)
Top Articles
Latest Posts
Article information

Author: Mrs. Angelic Larkin

Last Updated: 12/20/2022

Views: 6051

Rating: 4.7 / 5 (47 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Mrs. Angelic Larkin

Birthday: 1992-06-28

Address: Apt. 413 8275 Mueller Overpass, South Magnolia, IA 99527-6023

Phone: +6824704719725

Job: District Real-Estate Facilitator

Hobby: Letterboxing, Vacation, Poi, Homebrewing, Mountain biking, Slacklining, Cabaret

Introduction: My name is Mrs. Angelic Larkin, I am a cute, charming, funny, determined, inexpensive, joyous, cheerful person who loves writing and wants to share my knowledge and understanding with you.