Power Automate If Contains [With Examples]

While working on Power Automate flows, you can use the If() expression to validate the condition in a single line instead of taking multiple conditional branches.

In this tutorial, I will describe how to use the Power Automate If contains expressions with a few examples.

  • Power Automate If Contains Text
  • Power Automate If Contains Null
  • Power Automate If String Contains Value
  • Power Automate If Array Contains

Power Automate If Contains Text

I will show you how to use the If contains expression in a Power Automate cloud flow with a scenario.

Scenario: Suppose I have a SharePoint list named ‘Customer Contacts List‘ with a few columns.

I require that if the Mobile Number column contains a default value [NA], it should be updated to “Update Mobile Number.”

If Contains Text in Power Automate

Steps:

1. Go to Power Automate and create an Instant Cloud flow by manually triggering a flow from the SharePoint connector.

2. Add the Get Items action to fetch items from a SharePoint list. Provide the required parameters, such as the Site Address and List Name.

Power Automate if condition is null

3. Now, take Compose action to take the column value [Mobile Number ]from the dynamic content.

Each loop will be automatically added by taking the body/values from the Get items action.

Power Automate if expression contains null

4. After this, add another Compose action to check if the column [Mobile Number ] contains any default text value.

Add the expression below to the Inputs section.

if(contains(outputs('Compose_-_Mobile_Number'),'NA'),'Update Mobile Number',outputs('Compose_-_Mobile_Number'))
Power Automate condition expression null

5. Add the Update item action to update all the text values in the SharePoint list column [Mobile Number].

  • Site Address: Choose the Site Address where your SharePoint list is present.
  • List Name: Select the desired SharePoint list.
  • Id: Take ID from the dynamic content of the get items action.

Click on Show all to display the Advanced parameters.

  • Mobile Number: Choose and add outputs of the compose action.
If statement null in Power Automate

Now click on Save and run the flow manually.

6. Once the flow runs successfully, all blank values in the SharePoint list column[Mobile Number] have been updated with the text[Update Mobile Number].

If function contains in Power Automate

This is one of the examples of how to use an if condition that contains text in PowerAutomate.

Power Automate If Contains Null

Power Automate If contains null expression generates an error, as it should not be able to accept a null value.

This is because the contains() functions expect parameters of matching types: a dictionary and a key (string), an array and a value (object), or a string and a substring. If the null values are present, an error will be generated.

Error: Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'contains' expects parameters of matching types: a dictionary and a key (string), an array and a value (object), or a string and a substring. The provided types 'String' and 'Null' are incompatible. Please see https://aka.ms/logicexpressions#contains for usage details.'.
Power Automate If contains null

Power Automate If String Contains Value

To explain if the string contains a value in Power Automate, follow the below steps:

Scenario: Sending a canceled notification to the employees for a Flight ticket type as Business class.

I have a SharePoint list [Travel authorization] with a few columns. The Flight Details column contains a specific value [FlightTicketType].

If the Flight Details column contains [FlightTicketType: Business] -> Send an email to employee.

Column NameDataType
Employee NameSingle line of text
Flight DetailsMultiple lines of text
DepartmentChoice
Start DateDate and Time
End DateDate and Time
Power Automate if string contains value

Check Out the Steps:

1. Create a Power Automate Automated Cloud flow -> Select When an item is created trigger -> Choose Site Address and List Name.

Power Automate if string contains value example

2. Next, take a Compose action to check whether the string contains a specific value.

Add the code below to the Inputs parameter.

if(contains(triggerBody()?['FlightDetails'],'FlighTicketType: Business'),'Yes','No')
Power Automate condition contains text value

4. After that, add a Condition control to check if the output returned from the compose action is true.

Outputs('Compose') is equal to Yes
Power Automate If contains specific value

5. Under True branch, add a Send an email(V2)action, to notify an employee that the Travel request has been cancelled.

Configure the parameters like To, Subject, and Body.

Power Automate Condition if string contains a specific value

6. Once the flow is completed, Save and Test the flow. Go back to the SharePoint list and add an item as shown in the image below:

Check If text contains a value with Power Automate

7. If the condition satisfies, it will send an email to the employee, as represented in the screenshot below:

If string contains value in Power Automate

Power Automate If Array Contains

There is a complete tutorial on Power Automate If Array, which contains a value with different examples.

You can click the link below to learn if an array contains examples in Power Automate.

Check If an array Contains a Value using Power Automate

Conclusion:

I hope this Power Automate tutorial has taught you how the If contains() function works in Power Automate with all the related examples like:

  • Power Automate If Contains Text
  • Power Automate If Contains Null
  • Power Automate If String Contains Value
  • Power Automate If Array Contains
>

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…