Do you know how to remove items from Power Apps Collection? This Power Apps tutorial will explain removing item(s) from the Power Apps collection.
Here, we will discuss the Remove() function to remove or delete an item from the Power Apps collection and how to use the RemoveIf() function to remove a specific item from the Power Apps collection.
Additionally, we will cover how 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 Power Apps Collection
Suppose there are some unwanted records that you want to remove the item from the Power Apps collection. Then, in that case, you can remove those items by using the Power Apps Gallery control itself.
When you remove the item from the gallery control, that specific item will automatically be removed from the Power Apps collections.
To remove each item from the Power Apps collection, There are two ways to remove items from the Power Apps collection. Such as:
- Remove a Single item from Power Apps Collection
- Remove all items from Power Apps Collection
Remove a Single item from Power Apps Collection
Now, we will discuss how to remove a single item from the Power Apps collection using two functions. Such as:
- Remove a Single item from Power Apps Collection using Remove()
- Remove a Single item from Power Apps Collection using RemoveIf()
Remove a Single item from Power Apps Collection using Remove()
Let’s see how to remove a single item from the Power Apps collection using the Remove() function with a simple example.
Example:
I have a Power Apps collection named “colEventRegistration” containing the below records/items.
Refer to the below image:
Now, I want to delete a specific item, and the result will be displayed on the Gallery control control as in the screenshot below.
To achieve the above example, follow the below-mentioned steps. Such as:
1. To create a Power Apps collection, select the App object [from the left navigation] and set its OnStart property to the code below.
OnStart = ClearCollect(
colEventRegistration,
{
Name: "John Smith",
CompanyName: "Buckeyee Furniture",
Occupation: "Training and development specialist",
Age: 34,
Gender: "Female"
},
{
Name: "Emma Reyna",
CompanyName: "Fox valley CPAs",
Occupation: "Accountant",
Age: 32,
Gender: "Female"
},
{
Name: "Kelven",
CompanyName: "Bugle Boy",
Occupation: "Daimond Tracker",
Age: 44,
Gender: "Male"
},
{
Name: "Lynee",
CompanyName: "Specific Appraisals",
Occupation: "Computer and Information Researcher",
Age: 40,
Gender: "Male",
PhoneNumber: 5360875
},
{
Name: "Steve Mroz",
CompanyName: "Maxigraphics",
Occupation: "Graphic Designer",
Age: 39,
Gender: "Male",
},
{
Name: "Henrita Mullar",
CompanyName: "Happy Harry's",
Occupation: "Customer Suppot Executive",
Age: 36,
Gender: "Female"
}
)
Where,
- colEventRegistration = Power Apps Collection Name
- Name, CompanyName, Occupation, Age, Gender = Collection Headers/Columns
- “John Smith”, “Buckeyee Furniture”, “Training and development specialist” = Collection Records/Rows
2. Insert a Gallery control and set its Items property as:
Items = colEventRegistration
3. Insert a Trash icon inside the gallery control and set its OnSelect property code below.
OnSelect = Remove(
colEventRegistration,
ThisItem
)
Where,
- colEventRegistration = Collection name
- ThisItem = We can select a specific item that we want to remove from a collection
4. Now, click the Trash icon to remove the specific item from a Power Apps collection, as shown below.
This is how to remove a single item from the Power Apps collection using the Remove() function.
Remove a Single item from Power Apps Collection using RemoveIf()
Next, we will see how to remove a single item from the Power Apps collection using the RemoveIf() function with a simple scenario.
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].
To do so, follow the below steps.
1. Open Power Apps Canvas app -> Add Data from a SharePoint Online list (Issue Tracker) like below.
2. Then, select the App (from the left navigation) and choose the OnStart property to create collections like below.
OnStart = ClearCollect(
colIssues,
'Issue Tracker'
)
Where,
- colIssues = Collection name
- ‘Issue Tracker’ = SharePoint Online list
3. Now, select a screen -> Insert a Data table and set its Items Property as:
Items = colIssues
4. To display the collection fields in the data table control, click on the Edit fields option and add fields as needed.
5. Now, click the Run Onstart button to display the Power Apps collection in a data table like the one below.
6. Then, insert a Button control (Remove Laptop) and set its OnSelect property as:
OnSelect = RemoveIf(
colIssues,
'Product Name' = "Laptop"
)
- colIssues = collection name
- ‘Product Name’=”Laptop” = It is a logical condition to remove specific items based on the product name
7. Now, click the button control to display the Power Apps collection without “Laptop” items as shown below.
This is how to remove a single item from the Power Apps collection using the RemoveIf() function.
Remove all items from Power Apps Collection
Here, we will see how to remove all items from a Power Apps collection.
Example:
I will also take the same Power Apps collection [colEventRegistration] for this example. Now, I want to remove all items from the collection and display the results on gallery control.
Refer to the below image.
To achieve the above example, follow the below steps. Such as:
1. On the Power Apps Screen -> Insert a Button (Remove All Items) control -> Set its OnSelect property code like below.
OnSelect = Clear(colEventRegistration)
Where,
- Clear() = This clear function is used to delete all records from a collection
- colEventRegistration = Power Apps Collection Name
2. Now, click on the button control to remove all items from the Power App collection like below.
This is how to remove all items from a Power Apps collection.
Remove Power Apps collection Items from Dropdown
Last, I will show you how to remove Power Apps collection items from the Dropdown control with a simple example.
Example:
I will also take the above Power Apps collection [colIssues] for this example. In Power Apps, 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, as in the screenshot below.
To work around this, follow the below-mentioned steps. Such as:
1. On the Power Apps Screen -> Insert a Dropdown control and set its Items and Value properties below.
Items = colIssues
Value = Product Name
Where,
- colIssues = Collection name
- Product Name = Collection column name
2. 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,
- colIssues = Collection name
- ‘Product Name’ = Collection column name
- drp_ProductName = Dropdown name
3. Select the specific item from the dropdown control and click on the Button control to remove the items as shown below.
This is how to remove a Power Apps collection item from the Dropdown control.
Conclusion
I hope 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.
Moreover, you may like some more Power Apps tutorials:
- How to Sort Power Apps Collection Alphabetically
- Set Power Apps Gallery Control Row Color
- Add Image to a Power Apps Collection
- Microsoft Power Apps Copilot
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com