This Power Apps tutorial will walk you through, how to remove all items from a collection in PowerApps. We will also see several examples of how to remove one or more columns or items from the Power Apps collection within apps.
I recently received a request while working in a canvas app to remove an item(s) from the Power Apps collection and display the remaining items. As a result, I conducted extensive research and created this tutorial on how to remove column(s) from the Power Apps collection.
It will also be discussed how to remove items from the Power Apps collection, which includes the following items:
- Remove all items from a Power Apps collection
- How to remove all except one column from a collection in Power Apps
- Remove a column from a collection in Power Apps
- How to remove multiple columns from a Power Apps collection
- Power Apps remove a row from a collection
- How to remove duplicates from a Power Apps collection
Power Apps collection Remove() function
First, we will discuss what a Remove function is and how to use this function to remove items, rows, and columns from the collection as well.
In Power Apps, there is an inbuilt function named Remove() that removes a specific record or multiple record(s) from the data source.
The syntax for the Power Apps remove function is:
Remove(Collection, items,...)
Remove all items from a collection Powerapps
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,
- ColCapital is the name of the new collection.
- 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.
- 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.
Now preview the app and we can see all the items will be removed from the collection once the button is clicked.
This is how to remove all items from a Power Apps collection.
Read Power Apps collection filter
How to remove all except one column from a Power Apps collection
In this section, we’ll look at how to remove all columns from the Power Apps collection except one. That means there is a collection with multiple columns, and we will remove all but one of them.
To meet this requirement, the following steps are:
- On the Power Apps screen, add a button control and set the Text as
- Insert the below expression on the button’s OnSelect property to create the collection when the button will click.
OnSelect = Collect(CollProduct, {Product: "Laptop", Manufacture: "Apple", Quantity: 252}, {Product: "Mouse", Manufacture: "Dell", Quantity: 115}, {Product: "Tablet", Manufacture: "Samsung", Quantity: 78}, {Product: "Desktop", Manufacture: "Lenovo", Quantity: 110}, {Product: "Mobile", Manufacture: "Apple", Quantity: 35});
Where,
- CollProduct is the name of the new collection name.
- Product, Manufacture, and Quantity are the name of the collection’s columns
- Add a Power Apps data table to the screen, and set the Items as CollProduct to display the collected data.
- Initially, it will not display the collected data. For this, click on the ‘Create Collection’ button while clicking on the Alt key. Now, it will display the collected data within the Power Apps data table control.
- Similarly, add another button control to the screen.
- Set the text as “Show one Column“.
- Insert the below expression on the OnSelect property.
OnSelect = ClearCollect(CollProductOne, ShowColumns(CollProduct, "Manufacture"))
Where CollProductOne is the name of a new collection, CollProduct is the name of the existing collection, and “Manufacture” is the name of the existing collection’s column to keep in the new collection.
- Similarly, add another data table control to display the collected data.
- Set the Items’ property as CollProductOne.
- Click on the button control while clicking on the Alt key. We can see the collected data will come with a single column.
This is how to remove all columns except one within the Power Apps collection.
Read Power Apps Create Collection Using Excel
How to remove one column from a collection in Power Apps
In this section, we will see how to remove one specific column from the Power Apps collection and display the rest columns.
Let’s take the above example of the Power Apps collection i.e., CollProduct and the required steps are:
- On that Power Apps screen, add a button control.
- Set the text as “Remove one Column“.
- Insert the following expression on the button’s OnSelect property.
OnSelect = ClearCollect(CollProductRemove, DropColumns(CollProduct, "Quantity"))
As per the above expression, the new collection i.e., CollProductRemove will remove the Quantity column and will display the rest two columns.
- Next, add a Power Apps data table to the screen and set the Items as CollProductRemove. Then click on the button and it will display the collected data within the data table shown below:
This is how to remove one specific column from the Power Apps collection.
Remove more columns from a Power Apps collection
Similarly, here we will see how to remove more columns from a Power Apps collection. let’s take the above example to implement this requirement. The required steps are:
- Insert the below expression on the button’s OnSelect property.
OnSelect = ClearCollect(CollRemove, DropColumns(CollProduct, "Quantity", "Product"))
Where,
- CollRemove is the name of the collection.
- CollProduct is the name of the existing collection.
- “Quantity” and “Product” is the name of the columns that will remove from the collection.
- Add a data table control and set the Items as CollRemove to display the collected data. Once the button is clicked the collected data will display on the data table shown below:
This is how to remove more columns from a Power Apps collection.
Read Power Apps Create Collection Using SharePoint List
How to remove row from a collection in Power Apps
We’ll see how to remove a specific row from the Power Apps collection in this section. That means we have a collection of Power Apps with some columns. Now, we’ll use the existing collection to create another collection that will remove the specified row and display the remaining rows.
For this, the required steps are:
- On the Power Apps screen, we have built a collection on the button’s OnSelect property. Also, display the collected data within a Power Apps Data table shown below:
OnSelect = Collect(CollProduct, {ProductNo: 1012, Product: "Laptop", Manufacture: "Apple", Quantity: 252}, {ProductNo: 1022,Product: "Mouse", Manufacture: "Dell", Quantity: 115}, {ProductNo: 1032, Product: "Tablet", Manufacture: "Samsung", Quantity: 78}, {ProductNo: 1042, Product: "Desktop", Manufacture: "Lenovo", Quantity: 110}, {ProductNo: 1052, Product: "Mobile", Manufacture: "Apple", Quantity: 35});
- Suppose, we want to remove the column whose ProductNo is 1032 from the collection. For this, insert another button control to the screen.
- Insert the below expression on the button’s OnSelect property to remove the specific row.
OnSelect = ClearCollect(CollRemove, CollProduct); Remove(CollRemove, LookUp(CollRemove, ProductNo = 1032 ));
Where,
- CollRemove is the name of the new collection.
- CollProduct is the name of the existing collection.
- ProductNo is the name of the collection’s column.
- Similarly, add another data table to display the newly collected data and set the Items as CollRemove.
Once we click on the button, we can see the collected data within the Power Apps data table.
This is how to remove a specific row from the Power Apps collection.
Read Power Apps Timer Control Examples
Remove duplicates in collection in power apps
In this section, we’ll look at how to remove duplicate values from the Power Apps collection. Assume we have a collection called “BookCollection” with columns like “Name” and “Author,” as well as the following repeated items:
But, as per the requirement, we want to remove the duplicate items from the above collection and only display the unique values.
To meet the requirement, add a button control to the screen. Insert the below expression on the button’s OnSelect property.
OnSelect = ClearCollect(CollUnique, Distinct(BookCollection, Name))
Where CollUnique is the name of the new collection, BookCollection is the name of the existing collection, and Name is the column that provides the distinct operation. That means we will remove the duplicates from the Name column.
Next, add a data table to display the distinct values. Set the Items as CollUnique. We can see the data table will display only unique values.
This is how to display the unique values within the Power Apps collection.
Conclusion
From this Power Apps tutorial, we learned all about how to remove column(s), and specific items from the Power Apps Collection. Also, we covered the following things based on different situations.
- Power Apps collection remove item
- Power Apps collection remove all
- Power Apps collection remove all except one column
- Power Apps collection remove one column
- Power Apps collection remove more columns
- Power Apps collection remove a row
- PowerApps collection removes duplicates
You may also like the following Power Apps tutorials:
- Power Apps Notify() function
- Power Apps Filter With Date Picker
- How to disable Power Apps date picker
- Power Apps Checkbox control within Gallery
- Power Apps Listbox items from SharePoint list
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.
Good