Power Automate IF Expression – How to Use

In this article, I will explain how the Power Automate IF expression works along with below-mentioned examples:

  • Power Automate If Expression Dynamic Content
  • Power Automate If Equals Expression
  • Power Automate If Greater Than

Power Automate IF Function Expression

Power Automate If condition is one of the most commonly used expressions in Power Automate flows. The If expression checks whether a given condition is valid.

  • If valid -> Returns true
  • If not valid -> Returns false

Syntax:

if(expression, valueIfTrue, valueIfFalse)
Example: If (equals(2,3),’ Yes’, ‘No’)
  • Returns Yes -> If the given values are equal.
  • Returns NO -> If the given values are not equal.

Power Automate If Expression Examples

Now, I will discuss some examples of using the If expression while building flows in Power Automate.

Example1:- Power Automate If Expression Dynamic Content

To explain the If expression in a variable of dynamic content, create an Instant cloud flow where a user manually triggers the flow.

Follow the below steps:

1. In Power Automate, select Instant Cloud flow -> Click on +Add an input to insert two number fields to take the values manually.

IF condition in Power Automate

2. After that, add an Initialize variable action to initialize the input values. Provide Name, Type, and Value.

I wanted to check whether the If statement is valid by comparing it with the input values.

Value: if(equals(triggerBody()?['number'],triggerBody()?['number_1']),'Yes','No')
Power Automate if expression

3. To check the output from the previous step, add a Compose action.

  • Inputs: Take the value from the dynamic content of a variable.
Power Automate if expression examples

4. Now, click on Save and Test icons. Run the flow Manually. Enter values in the number field.

Power Automate If condition variable

5. After the flow runs successfully, if the given number values equal, it will return ‘Yes’ or ‘No’.

Power Automate initialize variable If statement

Example2:- Power Automate If Equals Expression

I will describe how the If equals condition functions in Power Automate using an Excel spreadsheet as a data source.

Scenario: I have Excel data with a few columns like Employee Name, From, To, Mode Of Journey, and Accommodation Included. I wanted to update the Accommodation Included column value to Yes if the Mode of Journey is Flight.

Condition: if(equals(['Mode Of Journey'],'Flight'),'Yes','No')
If equals Power Automate

Follow the below steps:

1. Create an Instant Cloud flow by selecting the ‘Manually trigger a flow’ trigger.

2. Next, take a List rows present in a table action to fetch all the rows in an Excel spreadsheet.

Configure the details like:

  • Location: Select the location of the file.
  • Document Library: Choose the document library.
  • File: Select Excel file.
  • Table: Select the Table name from the drop-down.
If condition equals in Power Automate

3. After that, add a Compose action to take the if equals expression that finds out the items with Mode Of Journey equals Flight.

  • Inputs: Insert the below given expression.

Each loop will be added automatically by taking the body/value option.

if(equals(items('For_each')?['Mode Of Journey'],'Flight'),'Yes','No')
Power Automate if expression equals

4. Here, add a Condition to check whether the output from the previous step is ‘Yes‘, then update the column value in the Excel sheet.

Choose ValueOperatorChoose Value
@outputs(‘Compose’)is equal toYes
Power Automate expression If statement equals

5. After that, Under the True branch, choose the Update row action. Provide the parameters like Location, Document Library, File, and Table.

  • Key Column: Select the Key column from the drop-down to identify the row that we want to update.
  • Key Value: Choose the value from dynamic content.
  • Accommodation Included?: Add ‘Yes‘ as a value in this column.
Power Automate condition if equal to text

Save your flow. Then, manually trigger it. Once the flow runs successfully, you can see that the Excel sheet has been updated.

Result: Accommodation Included? -> ‘Yes’

Power Automate If equals expression

Example3:- Power Automate If Greater Than

Let’s discuss another example of Power Automate If expression, i.e., [If greater than].

Scenario: To explain this example, I will use one of my SharePoint lists named [Product List] with a few columns.

My requirement is whenever a user creates or modifies an item in the SharePoint list If the Product Quantity is greater than 1000-> Add that item to the Excel sheet [Bulk Products Purchase List].

SharePoint List [Products List]

Power Automate if greater than

Excel Sheet [Bulk Products Purchase List]

Power Automate if Expression greater than

Check Out the steps below:

1. On the Power Automate Home page, select Automated Cloud flow with the ‘When an item is created or modified‘ trigger.

Choose and select Site Address and List Name.

Power Automate if condition greater

2. After that, add a Compose action to check if the Product Quantity is greater than a specific value.

  • Inputs: Add the If expression given below.
if(greater(int(triggerBody()?['TotalQuantity']), 1000), 'Yes', 'No')
If expression greater in Power Automate

3. Then, take Condition action to check whether the If condition is valid or not.

Choose ValueOperatorChoose Value
Outputs(Compose)is equal toYes
Power Automate if expression condition

If the Condition is satisfied, the True branch will execute else the False branch will execute.

4. Under the ‘True‘ branch, add an action named Add a row into a table. Configure the properties below:

  • Location: Select the location where the Excel file is stored.
  • Document Library: Choose the document library (SharePoint site).
  • File: Select the Excel file (Bulk Products Purchase List).
  • Table: Choose the table name from the dropdown.

Click on the Show all button to display all the Advanced parameters.

  • Product Name: Select from the dynamic content.
  • Product Price: Choose from the dynamic content of a trigger.
  • Product Availability: Add value from the dynamic content of a SharePoint list.
  • Product Quantity: Take Product quantity value from trigger dynamic content.
Power Automate expression if statement greater

When the flow is ready, Click on Save and Test. Run the flow manually.

5. Now, go back to the SharePoint list. Add or modify the SharePoint list item as shown in below screenshot:

Power Automate If condition expression

6. When the flow successfully meets the True condition, an item from the SharePoint list will be added to the Excel Spreadsheet.

Refer to the image below:

If expression Power Automate

Conclusion

In this tutorial, I have covered the If expression in Power Automate and its syntax. Also, we have discussed how to use if expression in Power Automate flows with real-time examples.

You may also like:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…