How to Remove Items From Power Apps Collection?

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:

  1. Remove a Single item from Power Apps Collection
  2. 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:

  1. Remove a Single item from Power Apps Collection using Remove()
  2. 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:

remove an item from a power apps collection

Now, I want to delete a specific item, and the result will be displayed on the Gallery control control as in the screenshot below.

How to remove a single item from the power apps collection

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

See also  How to Customize SharePoint List Forms with Power Apps?

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
How to Remove Items From Power Apps Collection

2. Insert a Gallery control and set its Items property as:

Items = colEventRegistration
How to remove a power apps collection item

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
How to remove the power apps collection item

4. Now, click the Trash icon to remove the specific item from a Power Apps collection, as shown below.

How to remove a single item from power apps collection

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].

remove item from power apps collection

To do so, follow the below steps.

See also  How to Create Power Apps App From Excel?

1. Open Power Apps Canvas app -> Add Data from a SharePoint Online list (Issue Tracker) like below.

remove an item from power apps collection

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
remove item from the power apps collection

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.

remove an item from the power apps collection

5. Now, click the Run Onstart button to display the Power Apps collection in a data table like the one below.

remove a single item from power apps collection

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
remove a single item from the power apps collection

7. Now, click the button control to display the Power Apps collection without “Laptop” items as shown below.

remove item from a power apps collection

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.

Remove all items from a Power Apps Collection

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
Remove all items from Power Apps Collection

2. Now, click on the button control to remove all items from the Power App collection like below.

Remove all items from the Power Apps Collection

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.

See also  How to Check If Power Apps Dropdown is Empty?

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.

How to remove power apps collection item from dropdown control

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
How to remove power apps collection item from dropdown

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
remove power apps collection item from dropdown control

3. 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 from dropdown

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:

>