Power Automate Contains() Function

This Power Automate tutorial explains how to use the Power Automate contains() function. I will show you the contains() Power Automate string function with syntax and examples.

In addition, I will explain how to use this contains() function in a Power Automate flow based on a SharePoint list.

Power Automate Contains() Function

Microsoft provides many string functions in Power Automate to manipulate strings. One of the important functions is the contains() function in Power Automate. This function can be used with arrays or strings.

The Power Automate contains() function is used to check if the array or string contains a specific element or a substring value. If the string or array contains the value, then it will return the output as ‘True’ or return the output as ‘False’.

Note:

The contains function only works if the value contains exact matches only.

Contains() Function Syntax

This syntax of the Power Automate contains() function is:

Syntax: contains(collection: array|string, value: string)
              (OR) contains([string],[value])

Example: contains([‘European countries – Germany, France, Austria],[‘France’]) => Return the output as ‘true’.

The output datatype returned will be in the form of boolean values ‘true or false’.

Power Automate Contains() Function Examples

To understand this function, let’s implement it in a Power Automate flow that will trigger manually.

Follow step-by-step instructions to create a Power Automate flow.

Example 1:

1. Open the Power Automate home page by typing make.powerautomate.com in the browser. Click on “+Create” -> Select “Instant cloud flow. ” Then, set the flow name, choose “Manually trigger a flow,” and click on Create.

2. In this step, add an “Initialize variable” and set the details below.

  • Name: Set a name for an initialized variable
  • Type: Select datatype as ‘String’
  • Value: Here, I have given a text string value.
Power Automate Contains() Function

3. Finally, add a “Compose” data operation and set the Input value as placed in the code.

contains(variables('Power Platform'),'Power BI')

Where variables(‘Power Platform’) – String, and ‘Power BI’ – Value/element.

Power Automate string functions Contains() function

4. The flow is ready, and we can test it. Save the flow and Click on Test -> Manually to test flow.

Power Automate flow string functions Contains() function

5. The outputs of the compose action will display true like below if the string contains a specific value.

contains() in power automate

This is how to work with the Power Automate contains() function.

Example 2:

Now, let us discuss the second example of the Power Automate string contains() function, based on the SharePoint list.

Recently, I was working on a SharePoint list where the client is required to check whether a text column has specific values.

For that, I created a SharePoint list named “Course Enrollment Form” with datatypes as provided in the table below.

Column NameDatatype
Course to enrollSingle line of text -By default it is a Title column
Full NameSingle line of text
Date of EnrollingDate and Time column
contains() in power automate

Here, we wanted to verify whether the “Course to Enroll” column contains designated course values.

For this, build an “Automated cloud flow” in a Power Automate flow that will trigger automatically when an item is created or modified in a SharePoint list.

Follow the below step-wise process to implement it inside a flow.

1. In the Power Automate Home page, click on +Create and select “Automated cloud flow”. Then, set the flow name, choose the trigger “When an item is created or modified” and click on Create. Here are the details below:

  • Site Address: Select a site name from the drop-down.
  • List Name: Choose a list name from the drop-down.
contains() function in power automate

2. Next, add an “Initialize variable” flow action that stores variable value and is used during the flow. Provide details below.

  • Name: Give a name for the variable.
  • Type: Select datatype from the drop-down.
  • Value: Select value from the dynamic content.
contains() function in power automate

3. Finally, add a “Compose” data operation and set the details below.

  • Inputs: Take the below given code value in it.
contains(variables('Course'), 'JAVA')
contains() function in power automate

4. The flow has been created. Now, it’s time to test. Click on Save and Test -> Test Manually.

Power Automate Contains

5. Then, the outputs of the compose flow action will give the result as true or false if the text has that specific value.

Contains() expression in Power Automate

This is how to use the contains() string function in a Power Automate flow.

Conclusion

I hope you got an idea of Power Automate contains() function. I have explained how to use the contains() function in Power Automate with two examples. One is from a manual trigger flow that only shows the result of the contains string function. The other one is on automatically trigger flow using a SharePoint list.

You may like the following tutorials: