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 / Remove ThisItem in Col...
Power Apps
Answered

Remove ThisItem in Collection not working

(0) ShareShare
ReportReport
Posted on by 51

I have an app with a shopping cart using a collection (ColIrrParts) in a gallery (GalleryPartsCart). I have a trash can icon in my gallery with the OnSelect set to: Remove(ColIrrParts,ThisItem)

 

This only removes the first item in the collection and will not work for removing any other items in the collection. I cannot figure out why the remove function will not work properly. I wonder if it may be because I have added a TextInput in the gallery.

 

Here is the information on TextInput:

The TextInput Default is set to: ThisItem.Quantity

The TextInput OnSelect is set to: Select(Parent)

The TextInput OnChange is set to: Patch(ColIrrParts, GalleryPartsCart.Selected, {Quantity: TextInputQuantity.Text,Total: LabelItemTotal.Text});
Reset(TextInputPartsTotal)

 

It may not be related to the TextInput at all. Just cannot figure out this otherwise simple issue.

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @Nate0173 

    I wonder if you could make a simple fix by changing your code to this:

    Remove(ColIrrParts,LookUp(ColIrrParts, ID = ThisItem.ID))

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi  @Nate0173 ï¼š

    Firstly,I made a similar test but did not encounter the problem you described.

    I also did the test you described about the TextInput control, and I didn’t encounter any problems. The problem should have nothing to do with the TextInput control.

    Since there is a situation where only the first record can be deleted, I guess that the "thisitem" might points to the wrong address. It may be related to your gallery settings.

    Can you tell me what the gallery’s items property is?

    Secondly, here is my test for your reference:

    1\add a gallery and set it’s item property to:

     

    ColIrrParts

     

    2\ add a trash can icon into the gallery and set it’s item property to:

     

    Remove(ColIrrParts,ThisItem)

     

     

    1.jpg2.jpg3.png

     
     

    Finally, Thanks for @mdevaney â€™s solution, I think this is a good way to solve your problem. Have you tried it? Did you succeed?

    Best Regards,

    Bof

  • Nate0173 Profile Picture
    51 on at

    @mdevaney 

    I tried that code also and I get the error, "Name isn't valid. this identifier isn't recognized." referring to "ID" in both locations.

  • mdevaney Profile Picture
    29,991 Moderator on at

    @Nate0173 

    OK, that error means ID does not exist as a column in the collection.  I thought maybe you brought in some data from SharePoint which always has an ID column.

     

    Lets try something else.  How about this...

    Remove(ColIrrParts, Gallery1.Selected)

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • mdevaney Profile Picture
    29,991 Moderator on at

    @Nate0173 

    OK, that error means ID does not exist as a column in the collection.  I thought maybe you brought in some data from SharePoint which always has an ID column.

     

    Lets try something else.  How about this...

     

    Remove(ColIrrParts, Gallery1.Selected)

     

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Nate0173 Profile Picture
    51 on at

    @mdevaney 

    That doesn't seem to work either. I found that it stops working when entering formulas outside the gallery using information inside the gallery. The three formulasI have are:

     

    TextInputPrice: Text set at: Text((If(Sum(ColIrrParts,Total)<.001,0,Text(Sum(GalleryPartsCart.AllItems,LabelItemPrice)))),"[$-en-US]$#,###.00")

    TextInputTaxTotal: Default set at: Text((RoundUp(((TextInputPrice+TextInputLaborTotal)*(TextInputTaxPercentage/100)),2)),"[$-en-US]$#,###.00")

    TextInputTotalAmount: Default set at: Text((TextInputPrice+TextInputLaborTotal+TextInputTaxTotal),"[$-en-US]$#,###.00")

     

    The "Remove" function worked fine until entering the formulas. It stopped once when entering in the first formula for TextInputPrice. I rebuilt the gallery and tried again. The second time it still worked after entering the TextInputPrice formula, but stopped after entering in the TextInputTaxTotal formula. Once it stops working, it will not work again even when I delete all formulas from all these TextInput fields. I have to rebuild the gallery again. There is something with these formulas that the "Remove" function doesn't like.

  • Nate0173 Profile Picture
    51 on at

    @v-bofeng-msft 

    I tried the solution @mdevaney  suggested and it doesn't work. You can see my explanation in my reply. It seems to revolve around my formulas outside the gallery. The "Remove" function works fine until adding formulas outside the gallery that ask for information within the gallery.

  • Verified answer
    Nate0173 Profile Picture
    51 on at

    I ended up making a duplicate of the app screen and deleting the original screen. Now it seems to be working fine. I never did figure out why it wouldn't work properly especially considering I used a duplicate of the screen and it works.

     

    Thank you @mdevaney  and @v-bofeng-msft  for taking time to look into this!

  • srose Profile Picture
    94 on at

    This was the only solution that worked for me.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard