How to Check If an array Contains a Value using Power Automate?

When working with Power Automate, there will be situations where we need to check if an array contains a specific value or a partial text.

For this, Power Automate has a function named contains() function to check whether an array or a string contains a specific value.

In this tutorial, I will explain how to check if an array contains a specific value using the Power Automate contains() function and show how to check if an array contains a certain string with the filter array action in Power Automate.

Power Automate Array Contains() Function

Power Automate contains() function will check if an array or string contains a partial text or a specific element.

The output returned will be ‘true‘ if the array or string contains a specific element; else, it will return as ‘false.’

Power Automate contains() function is case-sensitive; it only checks for the exact match of an element.

InputFunctionOutput
‘Lidia’, ‘Henrietta’contains(“Lidia”,”Henrietta”),’Lidia’true
‘Lidia’, ‘Henrietta’contains(“Lidia”,”Henrietta”),’Lidia Holloway’false

Power Automate Check if an Array Contains a Value using contains() function

Here, I will discuss how to check whether an array contains a specific element by using the Power Automate contains() function.

I have explained the Power Automate contains() function in the above section.

Example:

InputExpressionoutput
[“California”,”Florida”,”Texas”]contains([“California”,”Floria”,”Texas”],’Florida’)true

Check the below-mentioned steps:

1. Navigate to the Power Automate home page and click “+Create” -> Select “Instant cloud flow. ” Then, set the flow name, choose “Manually trigger a flow,” and click on the Create button.

2. Take a new step as the Initialize variable flow action to initialize the values of an array.

Configure the below parameters:

  • Name: Set a name for an initialized variable.
  • Type: Select datatype as ‘Array’.
  • Value: Here, I have taken the below-shown values.
Check if an array contains a specific value in Power Automate

3. Add a Compose flow action to include the contains() expression to check whether the array has a specific element or not.

Inputs: Provide the below-given expression in it.

contains(variables('United States'),'Florida')
power automate check if array contains value

4. Once the flow is ready. Save it and Test it Manually. Click on Runflow.

5. If the array contains a given element, the output will be returned as ‘true‘ as shown below:

Power Automate check if an array contains a value

This is how to use the Power Automate contains() function to check whether the array contains a specific value.

Check if an array contains a specific value in Power Automate using Filter Array

Let’s see how to check if the array contains a specific value from the Power Automate filter array action.

Scenario:

The image below shows a SharePoint list with a Country column [Single line of text].

I wanted to check whether the Country column contains a specific country [Egypt] or not.

Check if an array contains a certain string in Power Automate

Go through the below steps:

  1. Take Manually trigger a flow trigger.
  2. Next, add the ‘Get items‘ flow action to retrieve all the items from a SharePoint list. Select the Site Address and List Name.
Check if an array contains a specific value using Power Automate

3. Take an ‘Initialize Variable‘ flow action. Set a Name for a variable and datatype as ‘Array.’

How to find array contains a value in Power Automate

4. After that, add Append to array variable flow action. Set the below details:

  • Name: Choose a name from the drop-down.
  • Value: Select the ‘Country‘ column from dynamic content.

Then, For each loop will be added automatically.

Power Automate how to check specific value in a array

5. Take a ‘Filter array‘ flow action. Provide the below details:

  • From: Take the value of a variable[Countries]
  • Filter query: Give the below expression
 @contains(@{item()},'Egypt')                             
Check if an array contains a specific element with Power Automate

6. Now save and test the flow. Test it manually.

7. When the flow runs successfully, open the filter array and check whether the array contains a specific element or not.

Refer to the image below:

How to check if an array contains certain element with Power Automate

This is how to check if an array contains a specific value in the Power Automate filter array action.

Conclusion

I hope this tutorial helped you to check if an array contains a specific value or not using Power Automate.

Here, I have described two methods to check if the array contains a value in Power Automate.

  • By using Power Automate contains() function
  • Through Power Automate Filter array action

You may also like the following tutorials:

>

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…