Power Automate contains() Function: Syntax and Examples

A training coordinator I worked with wanted an email every time someone signed up for a Java course in their SharePoint enrollment list. Their flow used contains() to check the course name, and it worked in testing. Then real sign-ups started, and it missed half of them. People had typed “java” and “JAVA”, and contains() only matched “Java”.

That’s the one thing everyone should know about contains(): it’s case-sensitive. In this tutorial, I’ll show you how the function works with text, arrays and objects, how to make it ignore case, and how to use it in a Condition.

Quick answer: contains(collection, value) returns true if a string contains a piece of text, an array contains an item, or an object has a key. For example, contains('Power Automate for SharePoint', 'SharePoint') returns true. It’s case-sensitive, so for text, compare lowercase versions: contains(toLower(variables('Course')), 'java').

How the contains() function works

contains() takes two parameters: the collection to search, and the value to look for. It returns a Boolean, true or false:

contains('<collection>', '<value>')

Microsoft lists it with the collection functions, because the “collection” can be one of three things, and it behaves a little differently for each:

CollectionWhat it checksExampleResult
StringWhether the text appears anywhere in the stringcontains('Power Automate for SharePoint', 'SharePoint')true
ArrayWhether one of the items matches exactlycontains(createArray('North','South','East','West'), 'East')true
ObjectWhether the object has a key with that name (not a value)contains(json('{"state":"TX","zip":"75001"}'), 'state')true

For strings, partial matches count: contains('hello world', 'world') is true. For arrays, the whole item has to match: contains(createArray('North','South'), 'Nor') is false.

Example 1: Check whether text contains a word

Create an instant cloud flow with the Manually trigger a flow trigger. Add an Initialize variable action named Power Platform, of type String, with some text as the value:

Initialize variable action with a String variable named Power Platform and text about its products

Add a Compose action. In Inputs, open the expression editor (select the fx icon, or type / in the new designer) and enter:

contains(variables('Power Platform'), 'Power BI')
Compose action with a contains expression that checks the Power Platform variable for Power BI

Here’s the finished flow. Select Save, then Test > Manually > Test:

Flow with the Manually trigger a flow trigger, Initialize variable and Compose actions

Because the text includes “Power BI”, the Compose output is true:

Compose output showing true for the contains expression

Example 2: Check a SharePoint column

For the enrollment scenario, I used a SharePoint list called Course Enrollment Form with these columns:

ColumnType
Course to EnrollSingle line of text (the renamed Title column)
Full NameSingle line of text
Date of EnrollingDate and Time

Create an automated cloud flow with the SharePoint trigger When an item is created or modified, and pick the site and the list. (This trigger works with custom lists and libraries; Microsoft doesn’t support it on the Announcements, Contacts, Events or Tasks list templates.)

Add an Initialize variable action named Course with the Title column as its value:

Initialize variable action storing the SharePoint Title column in a Course variable

Then add a Compose action with this expression:

contains(variables('Course'), 'JAVA')
Compose action with a contains expression that checks the Course variable for JAVA
Flow with the SharePoint When an item is created or modified trigger, Initialize variable and Compose

Save the flow, select Test > Manually, and add an item to the list. For a course that doesn’t contain “JAVA” in capital letters, the output is false:

Compose output showing false because the course name doesn't contain JAVA

You don’t need the variable, by the way. You can check the column directly: contains(triggerBody()?['Title'], 'Java').

Make contains() ignore case

As the coordinator found out, contains('Java Basics', 'java') returns false. To match any capitalization, convert both sides to lowercase:

contains(toLower(variables('Course')), 'java')

If the search text also comes from dynamic content, lowercase it too: contains(toLower(variables('Course')), toLower(variables('Keyword'))). Not every text function works the same way, which catches people out:

FunctionCase-sensitive?
contains()Yes
replace()Yes
startsWith()No
endsWith()No
indexOf()No

Use contains() in a Condition

Usually you want the flow to do something based on the result. In a Condition action, you have two options:

  • Use the built-in operator: choose the column on the left, the contains operator, and the text on the right. It’s easier to read, but it’s case-sensitive too.
  • Use the expression: put contains(toLower(triggerBody()?['Title']), 'java') on the left, is equal to as the operator, and true on the right. Enter true as an expression, not as typed text, or you’ll be comparing against the word “true”.

For more examples, see Power Automate if contains and how to check a condition that contains a string.

Common problems

The flow fails when a column is blank

If the SharePoint column is empty, the value is null, and contains() fails with an error. Give it an empty string instead: contains(coalesce(triggerBody()?['Course'], ''), 'Java'). For more on blank values, see how to check if a string is empty.

It returns false for an array of objects

With an array of objects, such as the items from Get items, contains() compares whole objects, so it won’t find a single property. Use a Filter array action instead, with a condition on the property, and then check length(body('Filter_array')) is greater than 0. The check if an array contains a value tutorial walks through it.

You want to filter SharePoint items before they reach the flow

Use the Filter Query in Get items with SharePoint’s own function, for example substringof('Java', Title). It runs on the server, so the flow only gets matching items.

These Power Automate expression tutorials go well with contains():

Frequently Asked Questions

Is the Power Automate contains() function case-sensitive?

Yes. Wrap both values in toLower() to ignore case. Microsoft documents the function in its expression functions reference.

Can contains() check for a value in an array?

Yes. contains(createArray(‘North’,’South’), ‘South’) returns true. The whole item must match, not part of it.

How do I use contains() with a SharePoint column?

Use the column in the expression, for example contains(toLower(triggerBody()?[‘Title’]), ‘java’), and compare the result to the expression true in a Condition.

Why does contains() fail when the column is empty?

A blank column is null. Use coalesce(triggerBody()?[‘Column’], ”) to replace it with an empty string first.