How to remove items from a collection in Power Apps [With Examples]

This Power Apps tutorial will walk you through several examples of how to remove items from a Power Apps collection within apps.

I recently received a request while working in a canvas app to remove item(s) from the Power Apps collection and display the remaining items. As a result, I did a lot of research and came up with this tutorial on how to remove items from the Power Apps collection.

  • How to remove items from the Power apps collection?
  • How to remove all items from the Power apps collection?
  • How to remove the last item from the Power apps collection?
  • How to remove the first item from the Power apps collection?
  • How to remove multiple items from the Power apps collection?
  • How to remove items from the Power apps collection while unchecking the checkbox?
  • How to remove empty items from the Power apps collection?
  • How to remove items from the Power Apps collection by id?
  • How to remove items from the Power Apps collection based on condition?
  • How to remove Power Apps collection items via dropdown control?
  • How to remove items in the Sharepoint list via power apps collection?
  • What is the limitation to removing items from the Power Apps collection?

How to remove items from the Power Apps collection

We’ll go over how to remove a specific item from the Power Apps collection in this section. When a user selects a collection item, it is removed from the Power Apps collection. To meet this requirement, we are going to create a collection while the button is clicking, and the required following steps are:

  • On the Power Apps canvas app screen, add a button control.
  • Set the Text as Create Collection.
  • Insert the below expression on the button’s OnSelect property. As a result, the collection will create when the button is clicked.
OnSelect = Collect(ColCapital,{Country: "USA", Captial: "WASHINGTON"}, {Country: "UNITED KINGDOM", Captial: "LONDON"}, {Country: "VIETNAM", Captial: "HANOI"}, {Country: "THAILAND", Captial: "BANGKOK"}, {Country: "SPAIN", Captial: "MADRID"}, {Country: "RUSSIA", Captial: "MOSCOW"}, {Country: "UKRAINE", Captial: "KIEV"} )

Where,

  1. ColCapital is the name of the new collection.
  2. Country and Captial are the names of the collection’s columns.
Power Apps collection remove a row
Power Apps collection removes a row
  • To display the collected items, add a vertical gallery to the Power Apps screen.
  • Set the Items as ColCapital. But initially, the data will not visible in the gallery. For this, click on the button first. Then we can see the collected data will be shown below:
PowerApps collection remove a row
PowerApps collection removes a row
  • Now, add a trash icon to the above vertical gallery.
  • Insert the below expression on the icon’s OnSelect property.
OnSelect = Remove(ColCapital, ThisItem)

where ColCapital is the name of the collection that we have created, and ThisItem is the specific item to remove.

Power Apps collection remove item
Power Apps collection removes item

That’s it! Preview the app for now. As we can see, when we click the icon, the corresponding item is removed from the collection.

PowerApps collection remove item
PowerApps collection removes the item

From the above collection, we have removed 2 items by clicking on the trash icon. This is how to remove the item from the Power Apps collection.

Read How to remove all items from a collection in PowerApps

Power apps remove all items from collection

Similarly, in this section, we will see how to remove all items from the Power Apps collection. That means we can remove all the collection items via a button click.

To implement this need, we will create a collection on the button’s OnSelect property by using the below expression. So that, when the button is clicked a collection will create.

OnSelect = Collect(ColCapital,{Country: "USA", Captial: "WASHINGTON"}, {Country: "UNITED KINGDOM", Captial: "LONDON"}, {Country: "VIETNAM", Captial: "HANOI"}, {Country: "THAILAND", Captial: "BANGKOK"}, {Country: "SPAIN", Captial: "MADRID"}, {Country: "RUSSIA", Captial: "MOSCOW"}, {Country: "UKRAINE", Captial: "KIEV"} )

Where,

  1. ColCapital is the name of the new collection.
  2. Country and Captial are the names of the collection’s columns.

Next, add a vertical gallery to display the collected data and connect that vertical gallery to the collection i.e., ColCapial. Once the button is clicked the items will be visible in the vertical gallery.

Power Apps removes all from collection
Power Apps removes all from collection
  • Next, to remove all items from the collection, add another button control to the screen and make sure to place the button outside of the gallery.
  • Set the text property as Clear All.
  • Insert the below expression on the button’s OnSelect property.
OnSelect = Clear(ColCapital)

Where ColCapital is the name of an existing collection that we previously created.

Power Apps collection remove all
Power Apps collection remove all

Now preview the app and we can see all the items will be removed from the collection once the button is clicked.

PowerApps collection remove all
PowerApps collection removes all

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

See also  How to create a filter in Power bi

Also Read: Power Apps collection filter [With real examples]

Power apps remove the last item from collection

In this section, we will see how to remove the last item from the Power Apps collection. For this, we will create a collection in the Power Apps and add a button to the Power Apps screen. When the user clicks on the button, the last item will be removed from the respective collection.

To work with this scenario, the following steps are:

  • On the Power Apps screen, add a button control and insert the below expression on the OnSelect property to create the collection.
OnSelect = Collect(ProductModelCol, 'Product Model')

Where ProductModelCol is the name of the new collection and ‘Product Model’ is the name of the SharePoint data source.

Power apps remove last item from collection
Power apps remove the last item from collection
  • Again add another button control to the Power Apps screen. Insert the below expression on the button’s OnSelect property to remove the last item of the collection.
OnSelect = Remove(ProductModelCol, LastN(ProductModelCol,1))
PowerApps remove last item from collection
PowerApps remove the last item from collection

That’s it! Let’s click on the second button while clicking on the Alt key. We can see that it will remove the last item from the collection with every click.

This is how to remove the last item from the Power Apps collection.

Check out: Power Apps Create Collection Using Excel [Complete Guide]

How to remove the first item from the Power Apps collection

Similarly, let’s take another example, to see how to remove the first item from the Power Apps collection. That means, we are going to use the above example of collection, where we will remove the first item from the collection when the user clicks on the button.

To work with this scenario, the following steps are:

  • On the above Power Apps screen, update the button’s Text property to “Remove First Item”.
  • Insert the below expression on the button’s OnSelect property.
OnSelect = Remove(ProductModelCol, FirstN(ProductModelCol,1))
Power apps remove first item from collection
Power apps remove first item from collection

That’s all! Now, when the user clicks on the button while clicking on the Alt key, we can see that it will remove the first item from the data table on every click.

That is how to remove the first item from the Power Apps collection.

How to remove multiple items from the Power apps collection

In this section, we will see how to remove multiple items from the Power Apps collection at once. That means we are going to use the above Power Apps collection to remove multiple items at once via a button click.

Suppose, from the above collection, we want to remove the items whose Product type is equal to Laptop.

For this, the required following steps are:

  • On the above Power Apps screen, add a button control and give a Text property as per the need. (Ex- Remove Multiple Items)
  • Insert the below expression on the button’s OnSelect property to remove multiple items at once from the Power Apps collection.
OnSelect = RemoveIf(ProductModelCol, Product = "Laptop")

Where ProductModelCol is the name of the above-created Power Apps collection.

Power Apps remove multiple items from collection
Power Apps remove multiple items from collection

While clicking on the Alt key, press the above-mentioned button. We can see, it will remove all those items whose product type equals Laptop.

PowerApps remove multiple items from collection
PowerApps remove multiple items from collection

This is how to remove multiple items from the Power Apps collection.

Have a look: Power Apps Create Collection Using SharePoint List

How to remove items from the Power apps collection while unchecking the checkbox?

In this section, we will see how to work with Power apps to remove items from collection on uncheck. That means the item will remove from the Power Apps collection while we uncheck the checkbox control.

To work with this scenario, we are going to use the above collection, i.e., ProductModelCol, and the following steps are necessary:

  • On the Power Apps screen, add a vertical gallery and connect that gallery with the Collection to display the collected data shown below:
Power apps remove items from collection on uncheck
Power apps remove items from collection on uncheck
  • On the above gallery, add a Power Apps check box control. So that it will visible in every row of the vertical gallery.
  • Insert the below expression on the check box control’s OnCheck property.
OnCheck = Collect(CollSelectedProducts,ThisItem)

Where CollSelectedProducts is the name of the new collection to store the checked item from the gallery.

PowerApps remove items from collection on uncheck
PowerApps remove items from collection on uncheck
  • Similarly, insert the below expression on the checkbox control’s OnUncheck property to remove the items from the collection while the respective item will uncheck on the Power Apps gallery.
OnUncheck = Remove(CollSelectedProducts,ThisItem)
How to remove items from Power Apps collection on uncheck
How to remove items from Power Apps collection on uncheck
  • Next, add a Power Apps data table control and connect that data table with the CollSelectedProducts collection to display the stored items as well as removed items.
How to remove items from PowerApps collection on uncheck
How to remove items from PowerApps collection on uncheck

Let’s preview the app, and check some items (Suppose 3 items) from the Power Apps gallery.

Remove items from Power Apps collection on uncheck
Remove items from Power Apps collection on uncheck

Once we uncheck the items(Ex- remove 2 items) from the Power Apps gallery, it will remove those items from the Power Apps data table control.

Remove items from PowerApps collection on uncheck
Remove items from PowerApps collection on uncheck

This is how to remove items from the PowerApps collection on uncheck.

See also  How to Send Teams Messages using Power Automate?

Read: Power Apps Timer Control Examples

How to remove empty items from the Power apps collection

Now, we will see how to remove the empty items from the Power Apps collection. That means we will remove the empty or blank items from the Power Apps collection if they contain some such items.

Suppose, we have a collection named CollCapital, having some blank items in it. We have displayed that collection with the collected data within a Power Apps gallery as shown below:

Power Apps remove empty items from collection
Power Apps remove empty items from collection
  • To remove the empty items from the above Power Apps collection, add a button control and set the Text property as per the need. (Ex- Remove Empty items)
  • Insert the below expression on the button’s OnSelect property.
OnSelect = Remove(ColCapital, Filter(ColCapital, Country =" " Or Captial = " "))

Where,

  1. ColCapital is the name of the existing collection that we have created.
  2. Country and Captial are the names of the collection header.
PowerApps remove empty items from collection
PowerApps remove empty items from collection

Let’s preview the app and click on the mentioned button. We can see that the empty items will be removed from the data table control while clicking on the button.

Remove empty items from PowerApps collection
Remove empty items from the PowerApps collection

This is how to remove empty items from the PowerApps collection.

Check Post: Power Apps Notify() function [How to use with examples]

Power Apps collection removes items by id

In this section, we will see how to remove the items from the Power Apps collection by id. That means the user can remove the item from the Power Apps collection based on id with a button tap.

Suppose, we have a SharePoint list named Projects having some different types of columns including the default ID column shown below:

Power Apps collection removes items by id
Power Apps collection removes items by id

Let’s remove the item from the above SharePoint list whose ID equals to 68 by using the Power Apps collection. If this is the case, then the required following steps are:

  • On the Power Apps screen, add a button control and insert the below expression on the button’s OnSelect property to create a collection within the Power Apps.
OnSelect = Collect(collProject, Projects)

Where, collProject is the name of the new Power Apps collection and Projects is the name of the SharePoint data source.

  • Let’s click on the button while clicking on the Alt key. It will create the collection. To display those collected data within the Power Apps screen, add a data table control and connect with the collection.
PowerApps collection removes items by id
PowerApps collection removes items by id
  • Let’s add another button and set the Text property as per the need.(Ex- Remove by ID)
  • Insert the below expression on the button’s OnSelect property.
OnSelect = Remove(collProject,LookUp(collProject,ID = 68))
How to remove item from Power Apps collection by id
power apps collection removes items by index

Let’s preview the app and we can see that while clicking on the mentioned button, the specified id will be removed from the Power Apps collection.

power apps collection removes items by value
power apps collection removes items by value

This is how to removes items by id on the Power Apps collection.

Read: Power Apps Filter With Date Picker

Power Apps collection removes items based on condition

In this section, we will see how to remove the items based on the condition from the Power Apps collection. For this, we are going to use the above Power Apps collection i.e., “ProductModelCol” where we will remove items using condition via Power Apps.

Suppose, we want to remove the items whose title contains a specific text i.e., Lenovo or manaufacturer is equals to Lenovo.

Power Apps collection removes items based on condition
Power Apps collection removes items based on condition

To fulfill this requirement, the following steps are:

  • On this above Power Apps screen, add a button control.
  • Give a Text to the button for user understanding.
  • Insert the below expression on the button’s OnSelect property.
OnSelect = RemoveIf(ProductModelCol, Manufacturer.Value = "Lenovo" Or "Lenovo" in Title)

Where,

  1. ProductModelCol is the name of the existing collection.
  2. Manufacturer.Value is the name of the choice column of the collection as well as the SharePoint list.
  3. Title is the name of the text column of the collection.
PowerApps collection removes items based on condition
PowerApps collection removes items based on condition

We can see that while we click on the button, the items will be removed from the above collection that satisfies the mentioned conditions.

Removing Items from Power Apps Collection based on conditions
Removing Items from Power Apps Collection based on conditions

This is how to remove Items from the Power Apps Collection based on conditions.

See also  How to get days of month in Power Automate + 15 Examples

Also, Check: How To Set Default Date in Power Apps Date Picker

How to remove Power Apps collection items via dropdown control?

We’ll see how to remove items from the Power Apps collection using a dropdown control in this example. That is, we will use the above Power Apps collection and add a dropdown column that will display the Manufacturer’s options. When a user selects an option from the dropdown control and clicks on the specified button control, the items in the Power Apps collection are removed.

To work with this scenario, we are going to use the above example of the Power Apps collection, and the following steps are:

  • On the above screen, add a Power Apps dropdown control to display the items from the SharePoint choice column i.e., Manufacturer.
power apps collection removes items dropdown
power apps collection removes items dropdown
  • Add a button control to the screen, and insert the below expression on the button’s OnSelect property.
OnSelect = RemoveIf(ProductModelCol, Manufacturer.Value = 'Manufacturer_dd'.Selected.Value)

Where ProductModelCol is the name of the collection and Manufacturer_dd is the name of the dropdown control.

PowerApps collection removes items dropdown
PowerApps collection removes items dropdown

That’s it! Let’s preview the app and test it. Select an item from the Power Apps drop-down control (Ex- Lenovo). Then click on the above-mentioned button and we can see that it will remove the items from the Power Apps collection.

PowerApps collection removes items via dropdown
PowerApps collection removes items via dropdown

This is how to remove items from the Power Apps collection via dropdown control.

Read Post: How to Patch Power Apps Date Picker

Power Apps collection removes items in SharePoint list

We saw how to remove items from the Power Apps collection based on different scenarios. In this section, we will see how to remove items from within the SharePoint list.

That means we will remove an item from the SharePoint list via Power Apps. To work with this scenario, the following steps are:

  • Assume we’re going to use the above-mentioned SharePoint list called ‘Product Model,’ and we want to remove an item only from the list (Ex- Dell vostro 3510), not from the Power Apps collection.
power apps collection removes item in SharePoint list
power apps collection removes items in the SharePoint list
  • We have created a collection using the above SharePoint list on the Power Apps screen. Also, we have displayed those data via the Power Apps gallery shown below:
PowerApps collection removes item in SharePoint
PowerApps collection removes items in SharePoint
  • Add a button control to the above Power Apps screen and insert the below expression on the button’s OnSelect property.
OnSelect = RemoveIf('Product Model', Title = "Dell vostro 3510")
Delete SharePoint Item from PowerApps
Delete SharePoint Item from PowerApps
  • Let’s preview the App and we can see the specified item will be removed only from the SharePoint list once we click on the button.
PowerApps collection removes item in SharePoint list
PowerApps collection removes items in the SharePoint list

This is how to remove items from the SharePoint list via Power Apps.

Power Apps collection removes item limit

Do you know about the limitation when removing items from the Power Apps collection? We recently published an article in which we discussed the limitations of the Power Apps collection.

We recommend that you click on the above-mentioned link to learn more about the limitation.

Conclusion

From this Power Apps tutorial, we have learned how to remove items from the Power Apps collection based on different scenarios such as:

  • Power apps remove items from a collection
  • Power apps remove all items from the collection
  • Power apps remove the last item from the collection
  • Power apps remove the first item from the collection
  • Power apps remove multiple items from the collection
  • Power apps remove items from the collection on uncheck
  • Power apps remove empty items from the collection
  • Power Apps collection removes items by id
  • Power Apps collection removes items based on condition
  • Power apps collection removes items dropdown
  • Power apps collection removes items in the SharePoint list
  • Power apps collection removes item limit

Additionally, you may like some more Power Apps tutorials:

>