How to Remove Items from a Power Apps Collection?

This Microsoft Power Apps tutorial will teach us how to remove an item from a Power Apps collection. Then, will discuss the Remove() function to remove an item from the Power Apps collection.

Additionally, we will see how to use the RemoveIf() function to remove a specific item from the Power Apps collection. Also, we will learn to remove all items from a Power Apps collection and how to remove Power Apps collection items from the dropdown control.

How to Remove Items from a Power Apps Collection

Creating a Power Apps collection makes adding a group of similar items to a table easier. Also, you can easily remove the item from a Power Apps collection.

  • For example, I have a Power Apps collection, i.e., [colCarModels]. There are two columns in this collection.
  1. Car
  2. Price

Now, I want to delete a specific item, and the result will be displayed in a Gallery control [2nd image].

Remove an Item from Power Apps Collection

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

  • Open Power Apps with your valid Microsoft 365 credentials -> Select the app where you want to add a Power Apps collection -> Select a screen -> Insert a Button control (Collection of car models) -> Set its OnSelect property code like below.
OnSelect = ClearCollect(
    colCarModels,
    Table(
        {
            Car: "BMW",
            Price: 20000
        },
        {
            Car: "Toyota",
            Price: 10000
        },
        {
            Car: "Ferrari",
            Price: 15000
        },
        {
            Car: "Audi",
            Price: 17000
        }
    )
)

Where,

  1. colCarModels = Collection name
  2. Car, Price = Collection Headers/Columns
  3. “BMW”, 2000 = Collection Values/Items
Remove an Item in Power Apps Collection
  • Then, insert a Gallery control and set its Items property as:
Items = colCarModels
  • Next, click the button control [Collection of car models] to display the Power Apps collection.
Remove an Item from Power Apps Collection
  • Then, insert a Trash icon inside the gallery control and set its OnSelect property code like below.
OnSelect = Remove(
    colCarModels,
    ThisItem
)

Where,

  1. colCarModels = Collection name
  2. ThisItem = We can select a specific item that we want to remove from a collection
Power Apps collection remove item
  • Now, click on the Trash icon to remove the specific item from a Power Apps collection as shown below.
Power Apps collection remove an item

This is how to remove a specific item from a Power Apps collection.

Power Apps Collection RemoveIf()

Here, we will see how to work with the Power Apps Collection RemoveIf() function.

  • Let’s take a simple scenario: I have a Power Apps collection as “Issue Tracker“. I have added records based on the issue title and product name in this collection.
  • I want to remove specific items based on the value, i.e., [Laptop]. Also, the result will be displayed in a Data table control [2nd image].
How to remove item from Power Apps collection

To achieve this, follow the below-mentioned steps.

  • Open Power Apps Canvas app -> Add Data from a SharePoint Online list (Issue Tracker) like below.
Power Apps Collection RemoveIf
  • Then, select the App (from the left navigation) and choose the OnStart property to create collections like below.
OnStart = ClearCollect(
    colIssues,
    'Issue Tracker'
)

Where,

  1. colIssues = Collection name
  2. ‘Issue Tracker’ = SharePoint Online list
Power Apps Collection RemoveIf Function
  • Now, select a screen -> Insert a Data table and set its Items Property as:
Items = colIssues
  • To display the collection fields in the data table control, click on the Edit fields option and add fields as needed.
How to remove item from Power Apps collection
  • Now, click on the Run Onstart button to display the Power Apps collection in a data table like below.
How to remove an item from Power Apps collection
  • Then, insert a Button control (Remove Laptop) and set its OnSelect property as:
OnSelect = RemoveIf(
    colIssues,
    'Product Name' = "Laptop"
)

Where,

  1. colIssues = collection name
  2. ‘Product Name’=”Laptop” = It is a logical condition to remove specific items based on the product name
How to remove an item from a Power Apps collection
  • Now, click the button control to display the Power Apps collection without “Laptop” items as shown below.
How to remove an item from the Power Apps collection
  • Similarly, you can remove specific items based on respective product names, i.e., [Remove Mobile] and [Remove Outlook]. To do so, follow the below button control’s OnSelect property:
OnSelect = RemoveIf(
    colIssues,
    'Product Name' = "Mobile"
)                                                                                            // Remove Mobile related items



OnSelect =  RemoveIf(
    colIssues,
    'Product Name' = "Outlook"
)                                                                                           // Remove Outlook related items       
How to remove an item from Power Apps collection

This is how to remove a specific item from the Power Apps collection based on the condition.

Remove Power Apps collection items from the Dropdown

Let us discuss how to remove Power Apps collection items from the Dropdown control.

  • For example, I have a Power Apps collection, i.e., [colCarModels]. There is a dropdown control and a button control. When a user selects a specific item from the dropdown and clicks on the button, the specific item will be removed from the dropdown and the collection.
  • A user selects a specific item, i.e., [Laptop], and clicks on the button control. Then, the Laptop items will be removed from the dropdown and the collection.

Refer to the below screenshot:

Remove Power Apps Collection Items from Dropdown

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

  • On the Power Apps Screen -> Insert a Dropdown control and set its Items and Value properties below.
Items = colIssues
Value = Product Name

Where,

  1. colIssues = Collection name
  2. Product Name = Collection column name
Remove Power Apps collection items from dropdown control
  • Then, insert a Button control (Remove Selected Item), and set its OnSelect property as:
OnSelect = RemoveIf(
    colIssues,
    'Product Name' = drp_ProductName.Selected.'Product Name'
)

Where,

  1. colIssues = Collection name
  2. ‘Product Name’ = Collection column name
  3. drp_ProductName = Dropdown name
Remove Power Apps collection item from Drop-down
  • Select the specific item from the dropdown control and click on the Button control to remove the items as shown below.
Remove Power Apps collection item using dropdown control

This is how to remove a Power Apps collection item via drop-down control.

Remove All Items from a Power Apps Collection

Here, we will see how to work with Remove All Items from a Power Apps Collection.

  • For example, I have a Power Apps collection, i.e., [colCarModels]. There are two columns in this collection.
  1. Car
  2. Price

Now, I want to remove all items from the collection and display the results on gallery control. Refer to the below image.

Remove All Items from a Power Apps Collection

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

  • On the Power Apps Screen -> Insert a Button (Remove All Items) control -> Set its OnSelect property code like below.
OnSelect = Clear(colCarModels)

Where,

  1. Clear() = This clear function is used to delete all records from a collection
  2. colCarModels = Collection name
Remove All Items from Power Apps Collection
  • Now, click on the button control to remove all items from the Power App collection like below.
Remove All Items from a Power Apps Collection

This is how to remove all items from a Power Apps collection.

Furthermore, you may like some more Power Apps tutorials:

Conclusion

Whenever you want to remove an item from a Power Apps collection, you can use a Remove() or RemoveIf() function to delete a specific item.

This Power Apps tutorial taught us how to remove an item from a Power Apps collection. Then, we saw how to use a Remove() function to remove an item from the Power Apps collection.

Also, we discussed how to use the RemoveIf() function to remove an item from a Power Apps collection. Then, we learned how to remove Power Apps items from the dropdown control. Last, we covered removing all items from a Power Apps collection.