Power Apps Collection Contains [With Various Examples]

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.

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 the Specific Value
  • 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.
Power Apps Collection Contains Specific Value

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

  • Open Power Apps with valid Microsoft 365 credentials -> Create a Canvas app.
  • Then, select the App (from the left navigation) -> Choose the OnStart 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 a Specific Value
  • 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 the Edit fields option and add fields as needed.
Power Apps Collection Contains
  • 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
How to Filter Power Apps Collection Contains Specific Text
  • Then, insert another Data table and set its Items property as:
Items = Productcol
  • To display the collection fields in the data table control, click on the Edit fields option 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.
How to Filter Power Apps Collection Contains Specific Value

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

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 Check If Value Exists in Collection
  • 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 Existing Column Value

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
How to Check Power Apps Collection Contains Existing Column Value
  • Then, insert a Data table and set its Items property as:
Items = colEmployeeEmail
  • To display the collection fields in the data table control, click the Edit fields option and add fields as needed.
Check Power Apps Collection Contains Existing Column Value
  • 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.
Check Power Apps Collection Contains a Existing Column Value
  • 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 a Existing Column Value

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

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 Set Variable from Specific Value
  • 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 Set a Variable from Specific Value

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

  • On the Power Apps Screen -> Select the App (from the left navigation) -> Choose the OnStart 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 the Edit fields option and add fields as needed.
Power Apps Collection Set Variable from a Specific Value
  • 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 Set Variable from the Specific Value
  • 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 Set the Variable from Specific Value
  • Once, you click on the button control, you will get a variable value as “Yes” as shown below.
Power Apps Collection Set a Variable from the Specific Value

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

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: