web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How can I remove all i...
Power Apps
Answered

How can I remove all items in a collection from a SharePoint list?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have a collection of items that I want to remove from SharePoint. I want to remove all of the items when a button is clicked if they are in said collection. The items in the collection are added directly from a gallery that contains the SharePoint items, so the data is exactly the same.

 

I assume I need to use Remove, RemoveIf, or a combo of one of these with ForAll, but I cannot figure it out.

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    You can use the RemoveIf function.

    Without knowing specifics of you data, a generic example would be this:

    RemoveIf(yourSPList, ID in yourCollection.ID)

     

    I hope this is helpful for you. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes  , thanks for responding. I'm getting the following error:

    Invalid argument type (table). Expecting Boolean value instead.

    I've configured this as follows:

    RemoveIf('Call Metrics Reporting',ID=colItemstoDelete.ID)

    The collection can contain 1 or more items from an SP list, but they are literally captured from a gallery and stored in the collection.

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    You have used an equals operator (=).  Recheck the formula I posted, it uses an in operator.

    RemoveIf('Call Metrics Reporting',ID in colItemstoDelete.ID)

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Doh! That was the problem-child. Thank you much. You are a gentleman and a scholar.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Any time!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @Anonymous @RandyHayes 

    For my own learning, I'd be interested to know if this use of 'in' throws a delegation warning or silent delegation (my term, where you don't get a warning but the formula only returns up to 2000 items)?

     

    Seems to be a grey area in my knowledge I'd like to get more info about.

     

    Cheers

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    No, the in operator is not a delegable operator.  It will throw a delegation warning.

    The second term you refer to as silent delegation already has a name...it's called Data Row Limit.  It is controlled in the advanced settings.  If your Remove operation includes the removal of the amount of records you have in the limit, then it will not be complete. 

     

    If delegation on large data sources is a concern, then other provisions for removing are needed. Such as a slower, but usable, ForAll with an embedded RemoveIf.  Not very efficient.  And even that can be subject to delegation issues as well as record limit issues (depending on the amount).

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes 

    Thanks mate, always great to get you insights. I was thinking that you knew something I didn't because you were pointing the 'in' at a collection rather than a datasource and somehow this was different. Alas, not to be 🙂

     

    I will try to use 'Data Row Limit' more but I think my brain will always associate this process with the word 'silent' so that I remember to check my functions, lol.

     

    Great to see you back answering Qs on the forums as well mate. I enjoy your input and do my best to read and learn from it.

     

    Thanks again.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes, is there a way to configure this solution to avoid delegation issues as that is indeed a concern with the project I posted about? For example, would sorting the data prior to applying the RemoveIF at least ensure recent items are being deleted?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    Your delegation issue comes from the in operator.  In order to avoid the delegation, you would need to remove the use of that operator.

    One way to achieve this would be the use of a ForAll function - similar to this:

    ForAll(RenameColumns(colItemstoDelete, "ID", "removeID"),
     RemoveIf('Call Metrics Reporting',ID = removeID)
    )

     

    Also with this, as a bonus,  you can modify the base collection as you go (if you need to for some reason):

    ForAll(RenameColumns(colItemstoDelete, "ID", "removeID"),
     RemoveIf('Call Metrics Reporting',ID = removeID);
     RemoveIf(colItemstoDelete, ID=removeID)
    )
    
    -OR- (if you have some status column in the collection)
    
    ForAll(RenameColumns(colItemstoDelete, "ID", "removeID"),
     RemoveIf('Call Metrics Reporting',ID = removeID);
     UpdateIf(colItemstoDelete, ID=removeID, {status:"Removed"})
    )

    Just a little extra to keep in mind.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard