In this Power Automate Tutorial, we will learn what is an IF expression in Power Automate, what is its syntax, and how to use the If expression in a flow.
Also, by taking various examples, we will discuss the below topics such as:
- Power Automate IF expression
- Power Automate IF expression examples
- Power Automate If expression variable
- power Automate expression IF greater than
- Power Automate IF expression null
- Power Automate IF expression boolean
- Power Automate IF expression equals
- Power Automate IF condition is equal to
- Power Automate IF condition
- power automate expression if or
- Power Automate expression IF AND
- Power Automate condition if it is approved
- Power automate if an array contains
- Power Automate IF expression contains
- Power automate if person field is empty
- Power automate if the date is null
- Power Automate IF condition in email
- Power Automate checks if an input string is an integer or not
- Power Automate condition if the array is empty
- Power Automate condition if the field is blank
- Power automate IF date is today
- Power automate if a date is less than today
- Power Automate IF expression today is Monday
- Power Automate IF attachment name contains
- Power Automate IF date is greater than today
- Power Automate IF day of the week
- Power Automate IF cell is empty
- Power automate IF file exists
- Power automate IF column equals
- Power Automate condition IF the attachment exists
- Power Automate IF expression dynamic content
- Power Automate condition if string is empty
- Power Automate expression IF length
- Power automate IF the body is empty
- Power automate IF get items is empty
- Power Automate if the filename contains
- Power automate IF field changed
- Power automate check IF list is empty
Power Automate IF expression
Power Automate If Expression expresses the conditional statement. This is used to return the statement according to statements. If the statement matches, then it returns the true value, otherwise, it returns the false value.
The Microsoft Power Automate provides an IF statement that checks the logical expression or conditions in flow development. It checks whether the given statement is valid or not. If it is valid then it will return the True value otherwise it will return a false value.
Syntax:
In Power Automate, we can write the if expression within the Compose action. The syntax for the IF expression is:
if(expression, valeueIfTrue, valueIfFalse)
For example:
if(equals(12,21),'Equals','Not Equals')
The above expression checks the given values (12, 21) are equal or not and then it will return the output based on whether the expression is true or not. As both the values are not equal, so it will return the else part as ‘Not Equals‘.
The syntax of this expression is:
If(<expression>,True, False)
For example, we will insert below expression:
if(equals(1,0),'Same','Different')
Then it will return the output as ‘Different‘.
Also, read: Power Automate Multiple Conditions [With 19 useful examples]
Power Automate IF expression examples
Let us take an example of using an IF expression where we will insert an expression that will check whether the inserted date is greater than the current date or not. To create the flow, the following steps are:
- On Power Automate, click on Create (on the left navigation panel) > Instant Cloud Flow > Select the trigger ‘Manually trigger a flow‘ > Create.
- We can see, that the flow is started. Let’s insert an input inside the trigger, click on +Add an input > Date.
- Now, we will add the logic expression inside the flow via the ‘Compose‘ action. Click on the +New step > search and select the action ‘Compose‘ > Expression > Insert the below expression >Update.
if(greater(triggerBody()['date'],utcNow()),'The inserted date is greater than current date','The current date is greater')
Note – Here the ‘utcNow()‘ executes the current date i.e. 2022-05-04.
- To see the execution, click on save > Test it manually. It will ask to insert a random date to run the flow (For example, the inserted date is 2022-05-06). Then click on the Run flow.
- Now, as the inserted date is greater than the current date it returns the true value i.e., ‘The inserted date is greater than the current date‘.
This is how to give an example of IF expression in Power Automate.
Let’s take an example to check the condition whether it is true or not. For example, if the age of a person is greater than or equal to 18 then he is eligible to give a vote otherwise he is not eligible. Now we will see how to implement this logic through Power Automate.
Example-1: Using If expression
Step-1:
On Power Automate, first, we will trigger the flow manually. In that trigger, we will add the number as our input.
Step-2:
Now we will insert the below expression in a Compose action to check whether the person is eligible or not eligible to give a vote.
if(greaterOrEquals(triggerBody()['number'],18), 'Eligible', 'Not Eligible')
Now we will check the flow by running it. When we will test it, it will ask us to insert the person’s age. For example, we will insert 27.
We can see the final result will come as ‘Eligible’:
Similarly, let’s insert the age as 12, then it will return the output as ‘Not Eligible’:
This is how to use IF expression on Power Automate flow.
Read Power Automate vs UiPath
Example-2: Using IF(condition) action
In Power Automate, there is a Condition (Control) action to implement the condition. Now we will see how to use this action to check the condition of a flow.
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.
When we will test the flow, it will ask to insert the age. For example, we will insert the age as ’16’. As the value is not matched with the condition, so it will return the False value i.e. If no part:
This is how to use the If-Condition action in power Automate.
Check out: Power Automate Parallel Branch with Examples
Power Automate IF condition
In Power Automate, there is another way to apply a condition in the flow i.e. Condition control. Let us take the previous example of whether the inserted date is greater than the current date.
To create the flow, the following steps are:
- On Power Automate, create an Instant Cloud Flow that triggers it manually and has a date input inside it.
- Under the trigger, we will add a ‘condition‘ control where we will use values and operators such as:
- Choose a value (First)- Trigger Date (Select it from the dynamic content)
- Operator– Is greater than
- Choose a value (Second)- To get the current date use the below expression.
utcNow()
- If the condition matches, then it will return the true statement. So in the ‘If yes‘ section, add a compose action and set a true statement. Similarly, we will add a false statement in the ‘If no‘ section that will execute when the condition will not match.
Now the flow is fully complete. Let’s test it. Click on save > test > manually. It will ask to insert a date that you want to test (ex- 2022-04-04). Click on the run flow. As the inserted date is not greater than the current date (ex- 2022-05-04) so it returns the false statement.
This is how an IF condition works in a flow.
Power Automate IF expression null
Here, we will see how to handle the null value using the IF expression in Power Automate. For example, we have a Sharepoint list having the Student’s names (single line of text) and their result(number) included null value.
Now we will create a flow that will check if the result is null, then it will update it as 0. To create the flow, the following steps are:
- On Power Automate, create an Instant Cloud Flow that will trigger manually. Click on Create > Instant Cloud Flow > Manually trigger a flow > Create.
- To get all the items from the SharePoint list, we will add an action under the trigger. Click on + New step > Get items. Provide the SharePoint site name and the list name.
- To insert the condition, add a ‘Condition‘ control. Set the value as:
- First value – Result (Select it from the dynamic content)
- Operator – is equal to
- Second value – null (use as an expression)
- According to the condition, if the result is null then it will update as 0. In the ‘If yes’ section, click on +Add an action > Update Item. Set the properties such as:
- Site address- Provide the site address
- List name- Select the list name
- Id- Select Id from the dynamic content
- Title- Select Title from the dynamic content
- Result- 0
Now save the flow, click on test > Manually > Run flow > Done. We can see it will update those fields whose value has null.
This is how to check if the field is empty or null using Power Automate.
Power Automate If expression null [Another Example]
Here we will see how to deal with an empty or null value in Power Automate using IF expression. For example, if we insert any value as input then it will return that value as an output otherwise a null value will come.
Do you have any idea, how to implement this in Power Automate Flow? Fine, here is the answer.
Step-1:
In Power Automate, first, we will trigger the flow manually. Then we will add a Compose action. Here we can use any value(except integer) as input or we can use a null value by using a Null expression.
Step-2:
Again we will use Compose action, where we will use an expression that will check whether the input is null or not:
if(empty(outputs('Compose_2')),'Null',outputs('Compose_2'))
As per the condition, if there is a null value then it will return the output i.e. ‘Null‘; Otherwise, it will return the input value as output i.e. Howdy.
Let’s take another example, where we will use a null as input:
The output will appear like below:
As the input was a null value, so it returned the output as Null.
Similarly, we can use this logic on Condition action in Flow:
In condition, it will check if the output of Compose-2 is null then it will return the ‘If yes’ part; otherwise it will return the ‘If no’ part.
This is how to use the null expression in conditions in Power Automate to check the null value.
Read: Power Automate email body formatting
Power Automate IF condition is equal to
Here, we will see how to use the ‘equals‘ in an IF expression or a condition action. To implement this, we are going to use the previous SharePoint list (i.e. StudentResults) and also, and we will add a single line of text column (i.e. Grade) to show the grade.
Now we will create a flow that will check if the result is equal to 0 then the grade will fail otherwise it will be a pass. To create this flow, the following steps are:
- On Power Automate, create an instant cloud flow that triggers the flow manually.
- Then add an action ‘Get items‘ to retrieve all the items from the SharePoint list. Under the trigger, click on + New step > Get items. Provides the SharePoint site address and the list name.
- Next, add a condition control to check whether the result is equal to 0 or not, and then update the grade as per the result. Click on the + New step > Condition. Set the value and the operator as:
- Choose a value – Result (select it from dynamic content)
- Operator – is equal to
- Choose a value – 0
- If the condition matches, then it will move to the ‘If yes‘ section; otherwise, it will move to the ‘If no‘ section and update the grade as per the condition.
- In the ‘If yes‘ section, click on +Add an action > update item. Provide the site address and the list name, ID, and Title, in the grade, set the value as ‘Fail‘.
- Similarly, repeat this process in the ‘If no‘ section and set the value as ‘Pass‘ in the Grade column.
Let us save the flow and test it manually. Run the flow. We can see it will update the grade in the result list.
This is how to use equal to in a Power Automate IF condition.
Also, read: Power Automate Do until
Power Automate expression IF greater than
Here we will see how to use the math function ‘greater than‘ within a condition in a flow. To implement this, let’s create a flow and the following steps are:
- On Power Automate, create an Instant cloud that will trigger manually. (Follow the previous example to create this flow.)
- Inside the trigger, add 2 number inputs. Click on +Add an input > Number.
- To compare the number, we will add a ‘Condition‘ control or we will add a ‘compose’ action using ‘Greater than‘ to this flow. Here we are going to use a condition control action. Click on + New step > Condition. Set the values and the operator such as:
- Choose a value (first) – Number1 (From Dynamic content)
- Operator – Is greater than (select it from the drop-down)
- Choose a value (second) – Number2 (From Dynamic content)
- If the condition matches, then it will move to the ‘If yes‘ section and show the greater number or true statement. In the ‘If yes‘, click on + Add an action > Compose. Insert the below inputs:
Number1
is greater than
Number2
Note – Select both Number1 and Number2 from the dynamic content.
- Now save the condition and test it manually. Then it will ask to insert 2 dynamic numbers. For example, 51 and 25. Click on run flow to see the output.
- As the condition is true, so it will execute the ‘If yes‘ section; otherwise, it will execute the ‘If no’ section. So the output will look like the below:
This is how to implement if the condition is greater than.
Check out: Power Automate create a task in Microsoft Planner
Power Automate IF expression variable
Here, we will see how to use variables within Power Automate IF expression.
- Let’s create an instant cloud flow that will trigger the flow manually. Under the trigger, add an ‘Initialize variable’ action and initialize a float variable. Click on + New step > Initialize variable.
- Name- Value1
- Type- Float
- Value- 12.5
- Again, add another ‘Initialize variable‘ and initialize a float variable with a different value.
- Name- Value2
- Type- Float
- Value- 13.7
- To use these variables within an IF expression, add a compose action. Click on + New step > Compose. Insert the below expression as compose input.
if(lessOrEquals(variables('Value1'),variables('Value2')),'True','False')
- Now save the flow and test it manually. As per the expression if the first variable is less or equal to the second variable then it returns True otherwise returns False.
This is how to work with IF expression variable in Power Automate.
Power Automate If expression variable [Another Example]
Here we will see how to use the If condition to check variables in Power Automate. For example, if the variable is blank then it will give an output as ‘No value’ otherwise it will return the value assigned in the variable.
To implement this, we will assign an integer type variable in the flow:
Then we will use a compose action with an expression that will check whether the variable is blank or not:
if(equals(variables('VarNumber'),0),'No value',variables('VarNumber'))
As it is a blank variable, so the out will come as ‘No value’:
Similarly, if we insert any value on that variable then it will show that value as output:
This is how to use the If expression in a variable in Power Automate flow.
Power Automate If expression greater than
In Power Automate, there is a logical function named ‘greater(value, compare To)’ that returns true if the first argument is greater than the second argument.
For example, we will create a flow that will check whether the date has expired or will come. To implement this, we will trigger the flow manually where we will use the date as input.
Then we will use the below expression on Compose action:
if(greater(triggerBody()['date'], utcNow('yyyy-MM-dd')),'This is date will come','This date has expired')
Let’s check this flow by entering a random date that has already gone from today’s date:
Let’s take another example by inserting a future date from today(i.e. 11/18/2021):
This is how to compare two dates, string, float, and number using If expression greater than in Power Automate.
Read Power Automate Concatenate String
Power Automate IF Condition Boolean
In this example, we will see how to use boolean in a Power Automate IF condition. For this, we are going to use a SharePoint list based on faculties having some random data.
Apart from this, there is a ‘Yes/no‘ column ‘Attended‘ it mentioned whether the faculty attended that tutor or not.
Next, we will create a flow that will check whether the faculty is attending or not. To create the flow, the following steps are:
- On Power Automate, create an instant cloud flow that triggers it manually.
- Then add a ‘Get items‘ action that will retrieve all the items from the SharePoint list. Provide the Sharepoint list and the Site address.
- Next, add a ‘Condition‘ control and provide the below parameters:
- Value (first) – Attended (select it from the dynamic content)
- Operator – is equal to
- Value (second) – True (use it as an expression)
We can see it will create an apply to each loop automatically.
- In the If yes section, add a compose action. Inside the compose, insert the faculty in charge name, date, and attendee details.
- Now save the flow and test it manually. We can see it will show only those faculty’s data who attended the tutor.
This is how to use boolean in Power Automate IF condition.
Read: Power Automate Copy Folders + 10 Examples
Power Automate IF expression equals
Here, we will see how to use ‘equals‘ within Power Automate IF expression. To implement this, we will create an ‘Instant cloud flow‘ on Power Automate that trigger the flow manually.
- In that trigger add 2 number inputs where we can insert numbers randomly. Inside the trigger, click on +Add an input > Number.
- Then add a compose action where we will insert the below expression.
if(equals(triggerBody()['number'],triggerBody()['number_1']),'Equal','Not equal')
- Now, save the flow. Click on test > manually. We can see it will ask to insert two numbers. Press ‘Run flow‘. For example, we will insert 25 & 23.
As both the numbers are not equal, then the output will come as ‘not equal‘.
Refer: Power Automate Copy Files + 21 Examples
Power Automate If equals
A equals() function needs arguments to compare and return true if they are equals. Here we will see how the equals() function works with if expression on Power Automate.
To implement this function, we will take two values on our flow i.e. value1, value2.
Then we will use the expression to check whether the values are equal or not in a Compose action:
if(equals(triggerBody()['number'],triggerBody()['number_1']),'Both values are equal', 'Both are not equal')
Now our flow is ready to run. Let’s insert two values to check whether they are equals or not:
Similarly, if we will insert two different values then it will return the False(i.e. Both are not equal). This is how to check whether the values are equal or not in Power Automate.
Read How to convert decimal to whole number in Power Automate
Power Automate expression if or
Here we will see how to use the ‘or‘ operator in the IF expression within Power Automate.
For example, there is a SharePoint list named ‘Vehicles‘ having some columns and some random data such as:
Now we will create a flow, that will show those data whose state is equal to ‘Texas’ or ‘England’. To create this flow, the following steps are:
- On Power Automate, create an Instant cloud flow that triggers the flow manually.
- Under that trigger, add an action ‘Get items‘ that will fetch all items from the SharePoint list. Provide the SharePoint site address and the list name.
- Next, add an action ‘Apply to each‘ and set the ‘Value’ as an output from the previous step.
- Inside the ‘apply to each‘ add a ‘Compose‘ action using the below expression.
if(or(equals(item()?['State'],'Texas'),equals(item()?['State'],'England')),'Condition Satisfied','Condition Not satisfied')
Now save the flow and test it manually. We can see the output below:
Note- As there are 8 items and the 1st item satisfies both the conditions, the output came as ‘condition satisfied’.
Power Automate expression if or [Another Example]
Here, we will see how the OR operator works with Power Automate flow. An OR operator returns true when one of the conditions is true or both conditions are true. Otherwise, it returns false.
For example, we have 2 numbers inputs, where we will put 2 conditions. One is if the first number is equal to the second number or if the first number is greater than the second number then it returns TRUE; otherwise, it returns FALSE.
Let’s create a flow to implement our requirement:
First, we will trigger the flow manually and add 2 number inputs for inserting numbers dynamically.
Then we will add a condition action to check the condition using OR operator:
Similarly, instead of Condition action, we can use these conditions in an expression format like below and we can use this expression in a Compose action.
if(or(equals(triggerBody()['number'],triggerBody()['number_1']),greater(triggerBody()['number'],triggerBody()['number_1'])),'True','False')
Now our flow is ready to test. Let’s insert two numbers to check the conditions (make sure if one of the conditions is true then it returns true otherwise it returns false). For example, here we will take 50 and 45 as two inputs respectively. Have a look at the output:
This is how to use Power Automate expression if using OR.
Power Automate expression IF AND
Similarly, here we will see how to use the ‘AND‘ operator within the IF expression in Power Automate. Also, we are going to use the previous SharePoint list i.e. Vehicles.
Now we will create a flow, that will show those data whose country is equal to ‘USA’ and state is equal to ‘California’. To create this flow, the following steps are:
- On Power Automate, create an Instant cloud flow that triggers the flow manually.
- Under that trigger, add an action ‘Get items‘ that will fetch all items from the SharePoint list. Provide the SharePoint site address and the list name.
- Next, add an action ‘Apply to each‘ and set the ‘Value’ as an output from the previous step.
- Inside the ‘apply to each‘ add a ‘Compose‘ action using the below expression.
if(and(equals(item()?['Country'],'USA'),equals(item()?['State'],'California')),'Condition Satisfied','Condition Not satisfied')
Now save the flow and test it manually, run the flow. We can see from those 8 items, the 6th item satisfied the condition i.e. that contain both the country ‘USA‘ and the state ‘California‘.
This is how to do Power Automate IF expression using OR.
Read Microsoft flow Send an email showing wrong time for SharePoint list column
Power Automate if statement And
Here, we will see how to use conditional statement with AND operator on Power Automate. An AND operator returns true if both parameters are true; otherwise, it returns false. To implement this, we will take the example that was used previously.
We have already used one condition to check whether the VarArray contains a specified item(i.e. Ottawa) or not. Now, we will add another condition using And operator i.e. to check whether the length of the variable is greater than 5 or not. For this the flow will be:
Let’s run this flow to see the output:
As the length of the variable is 4 so the condition did not match and the output returns false. This is how to do Power Automate if statement AND.
Also, read: Power Automate Create PDF + 11 Examples
Power Automate condition IF it is approved
In this example, we will see how to work if the request is approved and then it will notify the requestor about the request.
To implement this, we have prepared a SharePoint list based on ‘Office Expenses‘ having some columns such as:
Columns | Type |
Expenses | Choice |
Units | Number |
Apply Date | Date and Time |
Created By | Default |
Status | Choice |
Now we will create a flow, that will when a user requests an office expense, then it will send to the HR and if HR approves the request then it will notify the user about the request. Also, update the status in the SharePoint list.
To create the flow, the following steps are:
- On Power Automate, create an automated cloud flow that will trigger when an item is created in the SharePoint list.
- On Power Automate > Create > Automated cloud flow > select the trigger ‘When an item is created‘ > Create. Provide the SharePoint site address and the list name.
- Then, it will create an approval request and send it to HR, waiting for the response. Click on +New step > select ‘Start and wait for an approval. Set the properties such as:
- Approval type – Approve/Reject – First to respond
- Title – Specify the title of the request.
- Assigned to – Give an email id who will respond to the request.
- Details – Set the request details using the dynamic content.
- Item link – Link to item (Select it from the dynamic content).
- Now, we will add a condition control and add values that will check if the response is equal to approve. Click on + New step > Condition control. Set the value as:
- Value– Responses approver response (From the dynamic content)
- Operator– is equal to
- Value– Approve
- If the response is approved, then it will send an email notification to the requestor. In the ‘If yes‘ section, click on + Add an action > Send an email. Set the requestor’s email id, email subject, and body.
- Next, the status will update in the SharePoint list. Under the ‘Send an email action, click on + Add an action > Update Item. Provide the SharePoint site address and the list name. Give the ID from the dynamic content and set the status as ‘Approved‘.
- Similarly, repeat this process in the ‘If no‘ section. Add both the ‘Send an email‘ and ‘Update item‘ actions. Set the status value as ‘Rejected‘. It will execute if the response is rejected.
- Now save the flow. Click on Test > Manually. For testing purposes, insert an item detail in the SharePoint list.
- It will send an approval request to the specified user or HR.
- Let us approve the request and we can see once the request approve it will send an email notification to the requestor.
- Also, we can see the status is got updated in the SharePoint list:
This is how to work with Power Automate conditions if approved.
Check out: Start and wait for an approval Power Automate [Complete tutorial]
Power automate IF array contains
In this example, we will see an array with the ‘contains‘ function in an IF using Power Automate. To implement this, the following steps are:
- Let us create an Instant cloud flow on Power Automate.
- Next, initialize an array variable. Click on +New step > Initialize a variable. Set the parameters such as:
- Name- VarArray
- Type- Array
- Value- [“Texas”, “California”, “Scotland”, “NewYork”]
- Now, add a compose action where we will add the below expression that will return a true value if the array contains a specific value (ex- England); otherwise, it will return the false value. Click on +New step > Compose > Insert the expression > Update.
if(contains(variables('VarArray'),'England'),true,false)
- Let’s save the flow and test it manually. We can see it will return the false value as the array does not contain the specified value i.e. England.
This is how to work with expression if an array contains a specific value using Power Automate.
Power Automate IF expression contains
Similarly, here we will see how to use the ‘contains‘ function in an IF expression without using an array. To implement this, we are going to use a SharePoint list based on Products having columns such as Title and vendor.
Now we will create a flow that will show the true value if the vendor column contains a specified value; otherwise, it will show the false value. To create the flow, the following steps are:
- On Power Automate, create an Instant cloud flow that will trigger the flow manually.
- Next, add an action ‘Get items‘ that will retrieve all the items from the specified SharePoint list. Click on +New step > Get items. Specified SharePoint site address and the list name.
- Add an action ‘Apply to each’ and set the ‘value‘ as an output from the previous step. Inside the ‘apply to each‘ add a compose action using the below expression.
if(contains(item()?['Vendor'],'Adobe'),'Yes','No')
Now the flow is ready to run. So save this flow and test it manually. We can see the output will come as NO where the vendor does not contain the specified value. Similarly, the output will come as Yes where the vendor contains ‘Adobe.’
This is how to do Power Automate IF expression using contains function.
Power Automate if statement contains [Another Example]
Here we will check how to check a string or array whether it contains a specified text or not. For this, we will initialize an array variable:
For example, we will check whether the array variable contains a specified value or not i.e. Ottawa. So we will add a Condition action to check this:
As the variable contains that value i.e. Ottawa, so it executes the If yes part.
This is how to check if a property exists or not in the array variable on Power Automate.
Read: Power Automate copy list item to another list with attachments
Power automate IF person field is empty
In this example, we will see how to check if a person’s field is empty in a SharePoint list using Power Automate. To implement this, we are going to use the previous SharePoint list named ‘Faculties‘ having a person field with empty data.
To create the flow, the following steps are:
- On Power Automate, create an instant cloud flow that triggers the flow manually.
- Then add an action ‘Get items’ that will retrieve all the items from the given SharePoint list. Under the trigger, click on + New step > Get items. Provide the SharePoint site address and select the SharePoint list.
- Add a ‘condition’ control action. Add the values such as:
- Value (first) – Faculty Incharge (from the dynamic content)
- Operator – is equal to
- Value (second) – null (Use it as an expression)
It will automatically create an ‘apply to each‘ loop.
- If the condition got matched, then it will show the specified data using a ‘compose‘ action. Click on + New step > Compose.
- Now the flow is ready to run, so save the flow and test it manually. We can see the output will appear like below:
This is how to handle Power automate if a person’s field is empty.
Power Automate IF Date is null
In this example, we will see how to check if the date has a null value in the Sharepoint list. Here, we are going to take the previous ‘faculties‘ SharePoint list with some little modification which means the date column has some null field.
To check the empty date column, we are going to create a flow and the following steps are:
- On Power Automate, create an instant cloud flow that will trigger the flow manually.
- To get all the items from the SharePoint list, add the ‘Get items’ action and provide the site address as well as the SharePoint list.
- Next, add an action ‘Apply to each’ under the ‘get items’ action and the ‘value’ from the dynamic content as the output of the previous step.
- Inside the ‘apply to each, add a condition control action where we need to insert the values such as:
- Value (First condition) – Insert the below expression
empty(items('Apply_to_each')?['Date'])
- Operator- Is equal to
- Value (Second condition) – Insert the below expression
bool('True')
- If the condition gets satisfied, then it will move to the ‘If Yes’ section and show a message to mention the date. Inside the ‘If yes’ section, add a compose action and add some messages.
Now, click on Save and test the flow manually. As the second item has a null date field, the condition got satisfied and the outcomes will look like the below:
This is how to check if the date is empty or null using the Power Automate flow.
Read: Power Automate get items examples
Power Automate IF condition in email
Here we will see how to use the IF condition in an email within Power Automate. For example, we have a SharePoint list based on a task list having some random columns and data such as:
Now we will create a flow that will notify the user if an item is modified by another user. For example, on the above list, all the items are modified by Sonam subhadarsini. According to the flow if any of the items is modified by a different user, then it will notify the main user i.e. Sonam subhadarsini via outlook.
To create the flow, the following steps are:
- On Power Automate, create an automated cloud flow > select the flow ‘When an item is created or modified > Create. Provide the SharePoint site address and the list name.
- Add a condition to check whether the modified person is the same or not to the main user. Click on +New step > Condition. Set the values such as:
- Value (for the first condition) – Modified by display name from the dynamic content
- Operator – Is not equal to
- Value (for the second condition)- Specify the main user name i.e. Sonam Subhadarsini
- In the ‘If yes‘ section, add an action to notify the main user. Click on +Add an action > Send an email. Set the properties such as give a user mail to whom want to send the mail, email’s subject, and body.
- Click on the Save button and test the flow. For testing purposes, let us modify an item from another user.
- We can see it will send an email notification to the specified user via outlook.
This is how to do Power Automate flow IF condition in email.
Power Automate If expression in email [Another Example]
Here, we will see how to use if condition with email in Microsoft flow. For example, we have a SharePoint list with some data and we want that whenever the data got modified or created by someone except the specified owner, then it will notify the owner.
To implement this, we have created a SharePoint list like the below:
Then we will create a flow that will check if the item is modified by someone except the specified then it will notify the owner.
Let’s create or modify an item from another user ID in the SharePoint list to check this flow.
As the new item is created by another user, so it will notify the owner or specified email id.
This is how to work with If expression in email in power Automate flow.
Read Microsoft flow change true to yes
Power Automate checks if an input string is an integer
Here we will see how to check whether the input is a string or an integer. For this, we will create a flow-on Power Automate. To create the flow, the following steps are:
- On Power Automate, create an Instant Cloud flow that will trigger the flow manually.
- Next, we will initialize a variable under the trigger. Click on +New step > Initialize a variable. Set the properties such as:
- Name – VarIsInteger
- Type – Boolean
- Value – true
- Similarly, again we will initialize another variable and set the parameters such as:
- Name – VarInput
- Type – String
- Value – 687xyz
- Next, add a ‘Compose‘ action and set the below expression to convert the ‘VarInput’ to an integer.
int(variables('VarInput'))
- Next, add a ‘set variable‘ and set the variable ‘VarIsInteger‘ as false. Click on +New step > set variable.
- Then go to the ‘Configure run after’ of the ‘set variable‘ action. Set it as ‘has failed‘ and click on ‘Done‘.
- Next, we will add a ‘Condition‘ action that will check whether the variable ‘VarIsInteger‘ is true or false. Click on +New step > Condition. Set the values and operator of the conditions such as:
- Value (First) – VarIsInteger
- Operator – is equal to
- Value (Second) – true
- Similarly, click on the ellipses and select the ‘Configure run after‘ of the condition action. Set it as ‘is successful‘ and ‘is skipped‘. Click on done.
- If the condition got satisfied, then it will return the true value; otherwise, it will return the false value. In the ‘If yes’ section adds a ‘compose’ action and set a return value i.e. Yes the input is an Integer.
- Similarly, add another compose action inside the ‘If no’ action and set a return value as well.
- Now the flow is ready, let’s save the flow and test it manually. Click on ‘run flow‘. we can see the output will come like below:
- Similarly, if we set the variable value (i.e. VarInput) as ‘678‘ or any numeric then the output will appear like below:
This is how to determine if a string is numeric using Power Automate.
Also, read: Power Automate conversion of string
Power Automate IF array is empty
There is a function ‘empty()‘ in Power Automate that will check whether an array/ object/ string is empty or not and return the output as a boolean i.e. true or false.
In this example, we will see how to check if an array is empty or not in Power Automate. To implement this, we are going to use the previous SharePoint list i.e. Faculties.
Now we will create a flow that will check whether the input array is empty or not. To create the flow, the following steps are:
- On Power Automate, create an Instant cloud flow that triggers the flow manually.
- Add a ‘get items‘ action that will get all the items from the specified list. Click on + New step > Get items. Provide the SharePoint site address and the list name.
- Next, add a ‘compose‘ action and add the ‘Date‘ as input from the dynamic content.
- Now, we will add a condition action that will check whether the array is empty or not. Set the properties such as:
- Value (first) – Insert the below expression
empty(outputs('Compose'))
- Operator – is equal to
- Value (second) – true
- Now click on save and test it manually. Press the button ‘Runflow‘ to check the output. We can see on there are 4 data in the list.
- But in the 2nd and 3rd turn, the output will come as ‘true‘ as there is no data in the 2nd and 3rd items.
This is how to check if an array is empty in Power Automate.
Power automate IF field is blank
In this example, we will see to check if a field is blank or not using Power Automate. Here we are going to use the previous Sharepoint list i.e. Faculties with some little modification. Such as:
Now we will create a flow that will check if a field is blank or not in the above SharePoint list. To create the flow, the following steps are:
- On Power Automate, create an instant cloud flow that will trigger the flow manually.
- Add the ‘get items‘ action to get all the items from the Sharepoint list. Click on +New step > Get items. Provide the site address and the list name.
- Add a condition control and set the values such as:
- Value – Department value (from the dynamic content)
- Operator – is equal to
- Value – null (use as an expression)
- In both the ‘if yes’ and ‘if no’ sections, add ‘compose‘ actions. Set a true value and a false value in each compose action.
- Now save the flow and test it manually. When we click on ‘Run flow’ we can see the output will come as in the 2nd run.
This is how to check if the field is blank in the SharePoint list using Power Automate.
Check: Power Automate Number Format
Power automate IF date is today
Here, we will see how to handle it if the date is today. For example, when a task is assigned to you in the Sharepoint list, it will check if the date is equal to the current date or today then it will create a task in the planner.
We have prepared a SharePoint list based on the task list.
Now we will prepare a flow that will check on a particular time and create a task if the date is equal to the current date accordingly.
- On Power Automate, create a scheduled cloud flow and set the repeat time as ‘1 day’. Click on ‘Create‘.
- Add a ‘Get items‘ action that will get all the items from the specified Sharepoint list. Click on +New step > Get items. Provide the site address and the list name.
- Add a compose action and format the current date using the below expression.
formatDateTime(utcNow(),'yyyy-MM-dd')
- Next, add a condition action to check if the start date is equal to the formatted current date (i.e. out of the compose action). Click on +New step > Condition. Set the value as:
- Value – Start date (from the dynamic content)
- Operator – is equal to
- Value – Output of the compose action
- If the condition matches, then it will create a task in the planner. Inside the ‘If yes’ section, click on +Add an action > create a task (under planner connector). set the group id, plan id, title, and Start date-time.
Now the flow is ready. To run the flow, click on test it manually and press the ‘run flow’ button. We can see it will create the 2 tasks in the planner as there are 2 dates equal to the current date in the SharePoint list.
This is how to do Power automate if a date is today’s date.
Power Automate condition if date equals today
Here we will see how to check whether the date is equal to today or not. Let’s say, we have a SharePoint list based on some products orders and their delivery report like below:
Now we will create a flow to trigger this SharePoint list and insert a condition to check whether the order date is equal to today’s date or not. If it equals to today’s date then it will notify to the owner or a specified user about the order.
For today’s date, we have insert the expression:
formatDateTime(utcNow(),'yyyy-MM-dd')
Let’s run the flow manually and create a new item where the order date is as same as today’s date.
Now we can see an email is sent to the specified user to notify about the item that ordered today:
This is we can compare a date on SharePoint list whether it is today’s date or not and notify about it on Power Automate.
Read How to get manager email or name in Microsoft Flow
Power Automate condition if date is blank
Here we will see how to check whether the date column in sharepoint list is blank or not in Power Automate.
For this, we will take the SharePoint list that we have created previously i.e. SalesOrder. Now we will create a flow that will check whether the Order date is empty or not.
Let’s run the flow and create a new item on SharePoint list having blank date column:
As the date column is blank, we can see it will execute the if yes part.
This is a way where we can check whether the date is empty or not in Power Automate using If expression.
There is another way by using Get-items function, we can check whether the date column in SharePoint list is blank or not:
Similarly, we can see the output is coming like below:
As the date field in the 3rd item is empty so the condition is satisfied on 3. This is how to check if a date field is blank or not in Microsoft Automate.
Power automate if a date is less than today
Similarly, here we will see how to check if a date is less than today’s date using Power Automate. We are going to use the previous SharePoint list based on the ‘task list’.
Now, we will create a flow that will notify the assignee via Outlook if the task’s start date is less than today’s date. To create the flow, the following steps are: (a little bit similar to the previous flow steps)
- On Power Automate, create an instant cloud flow that will trigger the flow manually.
- Add a ‘Get items’ action and provide the SharePoint site address and the list name.
- Add a ‘condition’ control and set the value as below:
- Value – Start Date (from the dynamic content)
- Operator – is less than (select from the drop-down)
- Value – Insert the below expression.
formatDateTime(utcNow(),'yyyy-MM-dd')
- If the condition matches, then it will send an email to the assignee. Inside the ‘If yes’ section, click on +Add an action > Send an email. Set the properties using the dynamic content.
- Now save the flow. Test it manually. Click on the ‘run flow‘. We can see it will notify the user about the task where the start date is less than the current date.
This is how to compare a Date if it is less than today in Microsoft flow.
Read: Power Automate SharePoint Get items filter query contains is not valid
Power Automate IF expression today is Monday
Here we will see how to check whether the current day is Monday or not. To check this, we will create a flow and the following steps are:
- On Power Automate, create an instant cloud flow and trigger it manually.
- Then add a ‘compose‘ action using the below expression that will show the current date in day format i.e. Monday, Tuesday, etc.
formatDateTime(utcNow(),'dddd')
- Next, we will add another compose action using the below expression that will check if the day is equal to Monday then the output will come as Monday; otherwise, it will come as the current day.
if(equals(outputs('Compose'),'Monday'),'Monday',outputs('Compose'))
- Now, save the flow and test it manually. We can see as the current day is Wednesday according to the current date i.e. 5/11/2022, the output will come as Wednesday.
This is how to check if today is Monday in Power Automate.
Power Automate IF attachment name contains
Here we will see how to set conditions if the attachment contains some specific name. For example, if the attachment contains ‘.pdf‘ or ‘.txt‘ or some specific name, then it will store the file inside a document library.
To create the flow, the following steps are:
- On Power Automate, create an automated cloud flow and select the trigger ‘When a new email arrives. Click on the create button.
- Expand the trigger, and set it as Yes on the ‘Include attachments‘.
- Add a ‘Get attachment‘ action that will get the attachments from the arrived email. Click on +New step > Get attachment. Set the properties such as:
- Message-Id– Message Id (From the dynamic content)
- Attachment Id– Attachments attachment id (from the dynamic content)
- It will create an ‘Apply to each’ loop that will check for each attachment inside the email.
- Inside the ‘Apply to each‘ and under the ‘Get attachment‘ action, add a ‘Condition‘ action, and set the values such as:
- Value – Name (from the dynamic content/)
- Operator – contains
- Value – .pdf
- If the condition matches, then it will go to the ‘If yes‘ section, and add a ‘Create file‘ action. Set the properties, such as:
- Site address – specify the SharePoint site address
- Folder path – Give the folder path of the specified document library.
- Filename – Name (from the dynamic content)
- File content – Content Byte (from the dynamic content)
Let’s save the flow, click on test > manually > Runflow. For testing purposes send an email to yourself with attachments.
We can see it will store only that file whose name contains ‘.pdf’ within the document library.
This is how to check Power automate if the attachment name contains.
Check: Power Automate add days to date
Power Automate IF date is greater than today
Here, we will see how to check whether the given date is greater than today’s date. To check this, let’s create a flow:
- On Power Automate, create an instant flow that triggers the flow manually. Add a Date input where we will insert a date to check.
- Add a condition action, to check whether the date is greater than today’s date. Set the values such as:
- Value (first) – Trigger date (from the dynamic content)
- Operator – is greater than
- Value (second) – Insert the below expression
utcNow('yyyy-MM-dd')
- Then in the both ‘If yes‘ and ‘If no‘ sections, add ‘compose‘ actions to show the true value and false value respectively like below:
- Now save the flow and test it manually. Insert a date to run the flow. For example – 6/18/2022. Then the output will appear like below:
This is how to check if a date is greater than today’s date.
Also read, Power Automate or Microsoft Flow delete all files in a folder
Power Automate IF day of the week
Here, we will see how to check whether the current date is a weekday or weekend (i.e. Sunday and Saturday) using a Power Automate. To create the flow, the following steps are:
- On Power Automate, create an Instant cloud flow that triggers the flow manually.
- Add a compose action using an expression that will retrieve the current DateTime according to UTC.
utcNow()
- Again, add another compose action using the below expression that will show whether the current date is a weekend or weekday.
if(or(equals(dayOfWeek(outputs('Compose')),0),equals(dayOfWeek(outputs('Compose')),6)),'Weekend','weekdays')
Now save the flow, test it manually, and click on run flow. According to UTC, the current date is 5/11/2022 i.e. a weekday. So the output will come as ‘weekday‘.
This is how to work with Power Automate IF day of the week.
Power Automate IF cell is empty
Now we will see how to check if a cell is empty in an excel file using Power Automate. For this, we have prepared an excel date such as:
Now, we will create a flow that will check whether the cell is empty or not. And, the following steps are:
- On Power Automate, create an instant cloud flow that triggers the flow manually.
- Next, add an action ‘List rows present in a table‘ and set the properties such as:
- Location – Specify the location from the drop-down list.
- Document library – Specify the document library where the file is stored.
- File – Select the excel file name.
- Table– Select the table name.
- Next, add an action that will initialize a boolean variable having a true value. Click on +Add an action > Initialize a variable.
- Name – VarIsCellEmpty
- Type – Boolean
- Value – true
- Add a ‘Apply to each action and set the ‘Value‘ as an output of a previous step.
- Inside this ‘apply to each‘, add a ‘condition’ control to check if the cell is empty or not. Click on +Add an action > Condition. Set the value as:
- Value – Insert the below expression
empty(item()?['Sales in 2022'])
- Operator – Isequalto
- Value – true
- If the condition matches, then it will move to the ‘If Yes’ section. So in the ‘If yes’ section, click on +Add an action > compose > Insert the variable (i.e. VarIsCellEmpty) as input.
- Similarly, in the ‘If no’ section, click on + Add an action > Compose > Insert the below expression.
not(variables('VarIsCellEmpty'))
- Now we will save the flow > test it manually > Runflow. We can see the output will be true, where the cell is empty i.e. 3rd run.
This is how to do Power Automate to check if a cell is empty or not in excel.
Check out: Power Automate flow with Microsoft teams
Power automate IF file exists
Here we will see when we copy files from one library folder to another, and how to handle if the file already exists in the destination folder.
For example, we have 2 document libraries a source library (with folder) and a destination library such as:
1 – Source library(Documents)
2 – Destination library(Copied files)
To create the flow, the following steps are:
- On Power Automate, create an automated and select the trigger ‘When a file is created (properties only)‘ > click on create. Provide the destination library SharePoint site address and the library name.
- Add another action ‘Get files (properties only)‘ that will get the properties of the file from the specified folder or document library. Click on the + New step > Get files (properties only). Add the site address and the library name.
- Next, we will add a ‘Copy file’ action that will copy the file from one library to another. Click on +New step > Copy file. Specify the properties such as:
- Current Site Address– Specify the source SharePoint site address
- File to Copy– Identifier (from the dynamic content of the ‘Get files’ action)
- Destination Site Address– Specify the destination SharePoint site address.
- Destination Folder– choose the destination folder where you want to store the files.
- If another file is already there– Select ‘Fail this action‘ from the dropdown.
Now save the flow, test it manually, and run the flow. Upload 2 files (including existed files) in the source library.
We can see it will copy only those files that do not exist in the destination library.
The action will fail if there is a file that already exists in the destination library.
This is how to do Power automate if another file is already there.
Power automate IF column equals
Here we will see if the column equals a specific value or another column and then how it works within SharePoint using Power Automate.
For example, we have a SharePoint list named as ‘Orders List‘ based on order details such as Title, OrderDate, ShippedDate, Created by, and Status(single line of text).
- Now we will create a flow that will check if both dates are equal in both the columns such as OrderDate and the ShippedDate, then it will send an email to the respective person who created that item and update the status as well. To create the flow, the following steps are:
- On Power Automate, create an instant cloud flow that triggers the flow manually.
- Then add a ‘Get items‘ action under the trigger. Provide the SharePoint site address and the list name.
- Next, add a condition action to check whether the order date and the shipped date are equal or not.
- If both columns are equal, then it will notify the respective user via Outlook. In the ‘If yes’ section, click on +Add an action > Send an email. Provide the properties such as:
- To – Created by email
- Subject – Specify the email’s subject
- Body – Specify the email’s body using the dynamic contents.
- Also, add another action to update the status field in the SharePoint list. Click on +Add an action > Update Item. Set the site address, list name, Id, and Title. In the status field enter the value as ‘Will deliver soon‘.
This is how to do Power automate flow if column equals.
Read: Power Automate shared mailbox
Power Automate condition IF the attachment exists
Here, we will see how to handle if the attachment exists in the arrived email. For example, we will create a flow, that will check whether the email has attachments or not, and if the attachment is there then it will save the email in the specified SharePoint folder.
To create the flow, the following steps are:
- On Power Automate, create an automated cloud flow that will trigger the flow when a new email arrives. On Power Automate, click on +Create > Automated cloud flow > Select the trigger ‘When a new email arrives (V3)‘ > Create.
- In that trigger expand the Show advanced option > Include Attachments > Yes.
- Add a Condition action and set the value such as:
- Value – Has Attachments (from the dynamic content)
- Operator – is equal to
- Value – true
- If the email has attachments then it will move to the ‘If yes‘ section. Inside the ‘If yes‘ section, add a ‘Get attachment‘ action that will get the attachment from the email. Click on +Add an action > Get attachment. Set the message-id and attachment id from the dynamic content.
- Inside the ‘Apply to each’ loop, add another action ‘Create file’ that will store the attachment in a specified SharePoint folder. Click on + Add an action > Create file. Set the properties such as:
- Site address – Specify the SharePoint site address
- Folder Path – Specify the folder path
- File Name – Name (Select it from the dynamic content)
- File Content – Content Byte (From the dynamic content)
- Now save the flow and test it manually. For testing purposes, send an email with an attachment from another user-id to yourself.
We can see as the email has attachments, it will store the attachments in the specified document library folder:
This is how to do the Power Automate condition if the attachment exists.
Power Automate IF expression dynamic content
Now, we will see how to use the dynamic content in Power Automate IF expression. For example, we have a SharePoint list names ‘Voters list‘ based on title, age (number), and eligible (yes/no).
Now, we will create a flow that will check whether the voter is eligible for voting or not according to their age. To create the flow, the following steps are:
- For this, we will create an automated flow that will trigger when an item is created in the SharePoint list. On Power Automate, click on + Create > Automated Cloud Flow > select the trigger ‘When an item is created‘ > Create. Provide the SharePoint site address and the list name.
- Add a compose action and insert the below expression that will check if the voter’s age s greater than or equal to 18 then the voter is eligible for voting.
if(greaterOrEquals(triggerOutputs()?['body/Age'],18),true,false)
- Next, add an ‘Update item‘ action that will update the ‘Eligible‘ column. Click on + New step > Update item. Provide the site address, list name, id, and title. In the ‘Eligible‘, insert the output from compose.
- Now save the flow. Test it manually and click on run flow. Insert a new item in the SharePoint list.
This is how to use IF expression with dynamic content in Power Automate.
Power Automate If expression dynamic content [Another Example]
Now we will see how to use the dynamic contents in IF condition on a Power Automate flow. For example, we have a SharePoint list that stores the students’ names, their numbers, and Grade. But we want to differentiate whether it is under grade A or grade B when we insert a dynamic number to the list.
Here is our SharePoint list:
Now we will create a flow that will automatically show the Grade of students according to their Total Numbers. Let’s say if the number is less than or equal to 50 then it is Grade B otherwise A, and the grade will automatically be updated on the SharePoint list.
It means when we insert any random number in the SharePoint list it will be updated automatically according to the Condition.
Now we will save the flow and test manually. Then we will insert data in the SharePoint list to see the result:
This is how to use dynamic content in Power Automate IF expression. You can Download this flow from here.
Power Automate Multiple if statement
Now we will discuss how to use the multiple if statement in Power Automate. Let’s take an example to see how it works. For example, we have a SharePoint list having students’ name, their total numbers, and Remarks.
Our requirement is when we insert the name and total number in the SharePoint list it will be sent an email with the Remarks and then the remarks will be updated in the SharePoint list.
For remarks, we have some conditions such as if the total number is greater than or equal to 85 then remarks will be ‘Excellent’. Similarly, if the total number is greater than or equal to 70 then remarks will be ‘Very Good’, if the total number is greater than or equal to 50 then the remark will be ‘Good’ otherwise it will be ‘Fail‘.
Let’s create a flow to automate this process when an item is created in the SharePoint list. Then we will add an expression (according to our requirement) on a Compose action.
if(greaterOrEquals(triggerOutputs()?['body/TotalNumber'],85),'Excellent',if(greaterOrEquals(triggerOutputs()?['body/TotalNumber'],70),'Very Good',if(greaterOrEquals(triggerOutputs()?['body/TotalNumber'],50),'Good','Fail')))
In the next step, we will add an action to send an email and then add another action to update the remarks in the SharePoint list.
Testing the flow
Let’s take an example to test and see how its works. For example, we will insert the student’s name and his total number:
We can see a mail in the outlook that will notify the result of the student with remarks :
Now we can see the remarks will be auto-updated on the SharePoint list:
Similarly, we inserted some numbers with decimal, the result will come like below:
This is how multiple if expressions work on Power Automate.
Power Automate if condition is equal to string
Here we will see how a condition executes if it matches with the specified string. Let’s say, we have a lecturer’s list having a title(single-line column) and department(choice column).
Our requirement is when we select any department then it will send a notification to the respective lecture. For example, there are 3 departments such as IT, Management, and Architect. When we select IT, it will notify the respective lecture of IT. Similarly, it will notify the lectures of Management and Architect as well.
Let’s create the flow to implement this:
First, we will trigger the flow when an item is created in the SharePoint list. Then we will add a condition action to satisfy the condition like below:
This flow will run automatically when an item is created in the specified SharePoint list. After creating data, it will check whether the department is IT or Management, or architect. According to the condition, it will send the email where the condition will meet.
Testing
Let’s insert data in the SharePoint list where the department is ‘architect’.
Now we can see it will notify the lecture assigned to the architect i.e. User5(a testing purpose user ID).
This is how to do Power Automate if a condition is equal to string.
Read Power Automate Delete all items in SharePoint list
Power Automate condition if string is empty
There is an empty() function that checks whether the input such as string, collection, a float is empty or not. Now we will see how to check a string variable is empty or null in Power Automate.
For this, here we will initialize a string variable like below:
Then we will use condition action using an expression, to check whether the string variable is empty or not:
empty(variables('VarString'))
The above flow will check if the expression is true i.e. if the string variable is empty then it executes the if yes. If the variable contains any value then it executes the if no parts.
Let’s test this flow and we can see as there is no value assigned in variable i.e. empty string so it executes the if yes part:
Similarly, we will test the flow by inserting a string value in a variable.
This is how to check a string variable is empty or not in Power Automate or MS flow.
Power Automate expression IF length
Now we will see how a length function works with IF expression on Power Automate. A length function is used to return the number of elements in an array or string.
Let’s take an example of an array, where it will check if the length of the array is less than 10, then it will execute the TRUE value; otherwise, it will return FALSE.
So for this, first, we will take an array variable by initializing it:
Now we will add a Condition action to check the conditions:
Our flow is ready now. Let’s check the output by running it:
As the length of the array is 4 and it is less than 10, so it returns the TRUE value i.e. if yes part. This is how to do Power Automate expression if length.
Power automate IF the body is empty
Here, we will see how to work with Power Automate if the body is empty. For this we will create a flow, the following steps are:
- On Power Automate, create an instant cloud flow that triggers the flow manually.
- Add a ‘Initialize variable’ action to initialize an array variable. Click on + New step > Initialize variable. Set the properties such as:
- Name- VarArray
- Type– Array
- Value– []
- Again add another ‘Initialize variable‘ action and initialize a boolean variable.
- Name- IsEmpty
- Type– Boolean
- Value– true (use this value as an expression)
- Next, add a condition control to check whether the variable (i.e. VarArray) is empty or not.
- Value– Insert the below expression
empty(variables('VarArray'))
- Operator– is equal to
- Value– true (use as an expression)
- If the condition matches, then it will return the true value i.e. If yes; otherwise it will return the ‘If no‘ section. So in the ‘If yes‘ section, click on +Add an action > Set variable. Set the variable ‘IsEmpty‘ to be true.
- Similarly, in the ‘If no‘ section, click on +Add an action > Set variable. Set the variable ‘IsEmpty‘ as false.
Click on Save > Test > Manual > Runflow. We can see as the variable i.e. VarArray has a value so the output will come as false.
This is how to check if the body is empty Power Automate.
Power automate IF get items is empty
Here, we will see how to handle if the ‘get items’ is empty. For example, we have prepared a SharePoint list having some random data such as:
Now we will create a flow that will check whether the ‘get items’ is empty or not. To create the flow the following steps are:
- On Power Automate, create an instant cloud flow that will trigger the flow manually.
- Under that trigger, add a ‘Get items’ action that will retrieve all the items from the SharePoint list. Click on +New step > Get items. Provide the site address and the list name. In the ‘Filter Query’, add the below query:
Note – As the list has no data in the vendor column that equals ‘Microsoft‘ that means the value is empty or null. To implement the process, we have taken a nonexistent value.
Vendor eq 'Microsoft'
- Add a condition action to check whether the filter value is there or not using an expression. Click on + New step > condition. Add below condition values:
- value – Insert the below expression
length(body('Get_items')?['value'])
- Operator – is equal to
- Value – 0
- If the condition matches then it will show the true value; otherwise, it will show the false value.
- In the ‘If yes’, add a ‘compose‘ action and give a true value such as: ‘The get items filter value is there‘.
- Similarly, in the ‘If no’, add another ‘compose‘ action and give a false value such as: ‘The get items filter value is not there‘.
Now, click on save and test the flow manually. We can see it will return a false value as there is no data that equals Microsoft in the vendor column.
This is how to handle if the get items action is empty in Power Automate.
Power Automate if the filename contains
Here we will see how to copy a file from one library folder to another if the file name contains a specific word. For example, we have 2 SharePoint document libraries and we have to copy files from the source library to the destination library based on a condition.
According to the condition, if the file name contains ‘Power Platform‘ or ‘Power Automate‘ then it will copy that file from the source library to the destination library.
Below are the following steps to create the flow:
- On Power Automate, create an automated cloud flow. Select the trigger ‘When a file is created in a folder‘ and click on Create. Provide the site address and the folder id (folder path).
Note -As the file name is encoded with Base64, it will not recognize the string that we enter in the condition, and as a result, the flow might fail. So we need to store the Base64 encoding into a string variable.
- Click on + New step > Initilize a variable. Set the properties as:
- Name – VarFileName
- Type – String
- Value – x-mx-file-name-encoded
- Add a condition control to check the file name. Click on +New step > condition and add the condition values such as:
- Value – VarFileName
- Operator – is equal to
- Value – Power Automate
- Then click on +Add > Add row > Or. Add another condition such as:
- Value – VarFileName
- Operator – is equal to
- Value – Power Platform
- If the condition matches, then it will copy that file from the source library to the destination library. In the ‘If yes‘ section, click on +Add an action > Copy file. Set the parameters such as:
- Current Site Address- Specify the source site address
- File to Copy– x-ms-file-id (from the dynamic content)
- Destination Site Address– Give the destination site address
- Destination Folder– Specify the destination folder path where the file will be stored
- If another file is already there– Select ‘Copy with a new name‘ from the drop-down.
Now save the flow. Test it manually. For testing purposes, upload some files in the source library including the specified name.
We can see it will copy only those files whose name contains ‘Power Automate‘ or ‘Power Platform‘.
This is how to do Power automate if the file name contains.
Power automate IF field changed
Here, we will see how to get a notification if a field is changed in the SharePoint field using Power Automate.
For example, there is a SharePoint list based on product’s order:
Now, we will create a flow that will notify the user (who created that item) via outlook, if the status field changed. To create the flow, the following steps are:
- On Power Automate, create an automated cloud flow. Select the trigger ‘When an item is created or modified, and click on create. Provide the SharePoint site address and the list name.
- Next, add an action ‘Get changes for an item or a file (properties only)‘ that will return information about columns that have changed within a given time window. Click on +New step > Get changes for an item or a file (properties only). Set the properties such as
- Site Address– Provide the SharePoint site address
- List or Library Name– Select the list or library name
- Id– Select ID from the dynamic content
- Since– Insert the below expression that will compare the current item with the respective old version.
sub(int(triggerOutputs()?['body/{VersionNumber}']),1)
- Next, add a condition action that will check whether the column or field has changed or not. Click on +New step > Condition. Set the conditional values and the operator such as:
- Value – Has Column Changed: Status (Select this field from the dynamic content)
- Operator – is equal to
- Value – true (insert it as an expression)
- If the field is changed, then it will send an email notification to the user who created the respective item. In the ‘If yes’ section, click on +Add an action > send an email. Set the properties as:
- To – created by email (from the dynamic content)
- Subject – specify the email’s subject
- Body – Specify the email’s body using the dynamic content.
- Now, save the flow and test it manually. Let’s change the status field (in the last item) to deliver.
- Now, we can see it will send an email notification to the user:
This is how to check if a field is changed in Power Automate.
Power automate check IF list is empty
Here, we will see how to check whether the list is empty or not using Power Automate. For example, there is a blank list on our SharePoint site.
Now we will create a flow that will return a true value if the list is empty otherwise it will return the false value To create the flow, the following steps are:
- On Power Automate, create an instant cloud flow that triggers the flow manually.
- Add a ‘Get items‘ action that will get the items from the provided SharePoint list. Click on + New step > Get items. Provides the SharePoint site address and the list name.
- Next, Initialize a boolean variable that will store whether the list is empty or not in boolean. Click on +New step > Initialize variable. Set the properties such as:
- Name – IsListEmpty
- Type – Boolean
- Value – true (used as an expression)
- Now, add a condition control action and set the values such as:
- Value – Insert the below expression
length(outputs('Get_items')?['body/value'])
- Operator – Is equal to
- Value – true (use as an expression)
- In the ‘If yes‘ section, add a ‘set variable‘ action and set the variable ‘IsListEmpty‘ as true; similarly, repeat this process in the ‘If no’ section and set the variable value as false.
Now click on save > test > manual > run flow. We can see as the list has no data, so the output comes as true.
This is how to check if a list is empty using Power Automate flow.
Also, you may like the below Power Automate tutorials:
- Power Automate Initialize Variable
- Power Automate convert time zone
- Power Automate Concatenate String
- How to convert decimal to whole number in Power Automate + convert decimal to percentage
- How to move files from OneDrive to SharePoint using Power Automate
- Scheduled cloud flow Example | Run Flow on a Schedule in Power Automate
Conclusion
From the Power Automate tutorial, we discussed how to use the If expression and If condition action in Power Automate. Also, we covered below such as:
- What is Power Automate IF expression?
- Do an example using Power Automate IF expression.
- How to use Power Automate If expression in the variable?
- How to use if expression with greater than function in Power Automate?
- How to use Power Automate IF expression with null value?
- How to use Power Automate IF expression with boolean value?
- How to use Power Automate IF expression with equals?
- How to use the If condition with ‘is equal to’ in Power Automate?
- What is Power Automate IF condition?
- How to use Power Automate expression IF OR?
- How to use Power Automate expression IF AND?
- How to handle if it is approved in Power Automate condition?
- How to use Power automate if an array ‘contains’ function?
- How to use Power Automate IF expression with the ‘contains’ function?
- How to handle if a person’s field is empty in Power automate?
- How to check Power automate if the date is null?
- How to send an email using Power Automate IF condition?
- Power Automate checks if an input string is an integer or not?
- How to do Power Automate condition if the field is blank?
- How to check if the array is empty using the Power Automate condition?
- Power automate IF date is today
- Power automate if a date is less than today
- Power Automate IF expression today is Monday
- Power Automate IF attachment name contains
- Power Automate IF date is greater than today
- Power Automate IF day of the week
- Power Automate IF cell is empty
- Power automate IF file exists
- Power automate IF column equals
- Power Automate condition IF the attachment exists
- Power Automate IF expression dynamic content
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com
please how do i resolve this
get items returns [] output.
the filter query returns the correct result but the output is empty