Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (2024)

by Preeti Sahu

In this Power Apps tutorial, I will explain everything related to the Power Apps Collection Contains.

First, we will see what the Power Apps Collection Contains. Then, we will discuss whether the Power Apps collection contains a specific value.

Additionally, we will learn the Power Apps check if the value exists in the collection and Power Apps collection set variable from a specific value.

Table of Contents

Power Apps Collection Contains

  • Microsoft provides many functions and operators in Power Apps to manage the data. Unfortunately, some functions may be missing from the Power Apps Canvas app, like Contains() function.
  • We can use the Contains () function to filter the Power Apps collection based on the specific word or text. You can also use the in and exactin operators to serve the same purpose as a Contains() function.

Power Apps Collection Contains Specific Value

Here, we will see how to work with Power Apps Collection Contains Specific Value.

Example:

I have a SharePoint Online list, i.e., [Product Details], and inside this, I have added columns with various data types.

Refer to the below table:

Column NameData Type
TitleIt is a default single line of text
ManufacturerChoice column
PriceCurrency column
PurchaseDateDate and time column
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (1)
  • Power Apps has a Data table control [1st image] with some records [retrieved from SharePoint list], as shown below.
  • In the data table, there is a column called Manufacturer. I want to filter this column based on all the Samsung values.
  • When a user clicks on the button [Collect filter data], the 1st data table will filter, and all the filtered results will appear in the 2nd below data table control.

To achieve the above example, follow the below-mentioned steps. Such as:

  • OpenPower Appswith valid Microsoft 365 credentials -> Create a Canvas app.
  • Then, select theApp(from the left navigation) -> Choose theOnStart and set its property code like below.
OnStart = ClearCollect( colProductThings, 'Product Details')

Where,

  1. colProductThings = Collection Name
  2. ‘Product Details’ = SharePoint Online List
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (3)
  • Then, select a screen -> Insert a Data table, and set its Items property as:
Items = colProductThings
  • To display the collection fields in the data table control, click theEdit fieldsoption and add fields as needed.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (4)
  • Now, we need to display the records based on the specific value. To do so, insert a Button control and set its OnSelect property code below.
OnSelect = ClearCollect( Productscol, Filter( 'Product Details', "Samsung" exactin Manufacturer.Value ))

Where,

  1. Productcol = Collection Name
  2. Filter() = This function to find a set of records that matches one or more criteria
  3. ‘Product Details’ = SharePoint Online List
  4. “Samsung” = It is the name of the column that we want to filter
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (5)
  • Then, insert anotherData tableand set itsItemsproperty as:
Items = Productcol
  • To display the collection fields in the data table control, click on theEdit fieldsoption and add fields as needed.
  • Now, click on the button control [Collect filter data] to display the Power Apps collection with only specific records, as shown below.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (6)

This is how to filter a Power Apps collection containing a specific value.

See also PowerApps nested gallery control example

Power Apps Check If Value Exists in Collection

Now we will see how to work with Power Apps Check If Value Exists in Collection.

Example:

  • I have a Power Apps collection, i.e., [colEmployeeEmail] with one column (Enter User Email).
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (7)
  • I have added a text input, button control, and data table on the Power Apps screen. When a new user comes and enters a user email address, it will be added to the data table.
  • If it is an existing value then, it will not take and it will give a notification message, i.e., [This User Email…] as shown below.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (8)

To work around the above example, follow the below steps.

  • On the Power Apps Canvas app screen -> Insert a Text label [Enter User Email] -> Add a Text input to enter a user email address -> Insert a Button control and set its OnSelect property as:
OnSelect = If( CountRows( Filter( colEmployeeEmail, 'Enter User Email' = txt_Email.Text ) ) > 0, Notify( "This User Email Address Already Exists, Please Enter New Email Address", NotificationType.Information ), Collect( colEmployeeEmail, {'Enter User Email': txt_Email.Text} ))

Where,

  1. If() = This function can help us to evaluate multiple unrelated conditions
  2. CountRows() = This function counts the number of records in a table
  3. colEmployeeEmail = Collection Name
  4. ‘Enter User Email’ = Column Name
  5. txt_Email.Text = Text input name
  6. Notify() = This function displays a notification message to the user at the top of the screen
  7. “This User Email Address Already Exists, Please Enter New Email Address” = Notification message
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (9)
  • Then, insert a Data table and set its Items property as:
Items = colEmployeeEmail
  • To display the collection fields in the data table control, click theEdit fieldsoption and add fields as needed.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (10)
  • Then, enter a user email address and click the button control [Submit]. Once you add different user emails, that will be added to the data table, as shown below.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (11)
  • Once you enter the existing column value, it will not take and you will get a notification message, i.e., [This User Email…] like below.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (12)

This is all about the Power Apps check if value exists in the collection.

See also How to Set Context Variable in Power Apps?

Power Apps Collection Set Variable from Specific Value

Let us discuss working with Power Apps Collection Set Variable from Specific Value.

Example:

  • Suppose I have a Power Apps collection, i.e., [Issuecol]. In this collection, I have added two columns:
  1. Product Issue
  2. Product Name

Refer to the below table:

Product IssueProduct Name
Laptop is not workingLaptop
Outlook issueOutlook
Mobile remote issueMobile
Laptop mouse is not workingLaptop
Repair Outlook ProfileOutlook
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (13)
  • Now, I want to check if the Power Apps collection contains a specific value, i.e., [Laptop or Outlook], and set the variable value as “Yes” as shown below.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (14)

To do so, follow the below steps. Such as:

  • On the Power Apps Screen -> Select theApp(from the left navigation) -> Choose theOnStart and set its property code like below.
OnStart = ClearCollect( Issuecol, 'Issue Tracker')

Where,

  1. Issuecol = Collection Name
  2. ‘Issue Tracker’ = SharePoint Online List
  • Then, insert a Data table and set its Items property as:
Items = Issuecol
  • To display the collection fields in the data table control, click theEdit fieldsoption and add fields as needed.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (15)
  • Now, click on the Run OnStart icon under the App section to display the collection on a data table as shown below.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (16)
  • Next, insert a Button control and set its OnSelect property code like below.
OnSelect = Set( varRecord, If( LookUp( Issuecol, "Laptop" exactin 'Product Name' || "Outlook" exactin 'Product Name', true ), "Yes", "No" ))

Where,

  1. Set() = This function works with global variables that are available in the entire app
  2. varRecord = Global Variable Name
  3. Issuecol = Collection Name
  4. “Laptop”, “Outlook” = Collection Columns
  5. “Yes” = true_value
  6. No” = else_value
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (17)
  • Once, you click on the button control, you will get a variable value as “Yes” as shown below.
Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (18)

This is all about the Power Apps collection set variable from a specific value.

See also Power Apps WeekNum and ISOWeekNum Function + Examples

Conclusion

Whenever you want to create a Power Apps collection containing a specific value, you can use [in] or [exactin]operators to display the specific records on a Power Apps collection.

Here, from this Power Apps tutorial, I have explained the Power Apps collection containing a specific value. Then, we discussed Power Apps check if a value exists in the collection.

Finally, we covered the Power Apps collection set variable from a specific value.

Also, you may like some more Power Apps tutorials:

  • How to Bind Power Apps Dropdown Items From Collection
  • Display Multiple Columns in Power Apps Dropdown
  • Create Power Apps Collection from Multiple SharePoint Lists
  • Sort Power Apps Collection Alphabetically
  • Remove Items from a Power Apps Collection
  • Validate Power Apps Dropdown Control

Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (19)

Preeti Sahu

Preeti Sahu is an expert in Power Apps and has over six years of experience working with SharePoint Online and the Power Platform. She is the co-author of Microsoft Power Platform: A Deep Dive book. As a Power Platform developer, she has worked on developing various tools using Power Apps and Power Automate. She also makes Microsoft 365 videos and shares them on YouTube.

Power Apps Collection Contains [With Various Examples] - Enjoy SharePoint (2024)
Top Articles
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 6008

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.