cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jonny_anything
Frequent Visitor

Remove specific item from linked spreadsheet (data source)

Hello,

 

I have a simple App that allows users to upload an item that is then added to a spreadsheet and visible on the site.

 

This seems to all work fine but I am trying to find a way for users to remove their own item if it is has sold/no longer available.

 

The items are uploaded via the screen below:

 

Screen Shot 2020-01-16 at 11.49.43 (2).png

 

And items are then added to a simple spreadsheet

 

Screen Shot 2020-01-16 at 11.38.37.png

 

What I ideally want to do is to allow users to click a button on an item page that will then remove a specific item from the spreadsheet (and the app).

 

I.e. a button on this page that will remove this item

 

Screen Shot 2020-01-16 at 12.01.54 (2).png

 

Wondering if anyone has any ideas on how best to approach this?

 

Thanks,

 

Jonny

 

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

@jonny_anything 

I recommend using @timl's solution above just using Remove() and referencing the record. They'll do the same thing, but if you have a product with the same name for whatever reason, they'll both be removed using the RemoveIf() and the product name.

View solution in original post

9 REPLIES 9
Anonymous
Not applicable

Check out the RemoveIf() function here
https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-remove-removeif
You'll use that along with some form of Gallery1.Selected.ID to remove a specific row. Let me know if you get stuck and I can walk you through it!

Hi @Anonymous 

 

Thanks for responding so quickly on this.

 

Apologies, I’m not that clued up when it comes to PowerApps. So essentially if I added a button on the page would it be something like:

 

OnSelect  -

RemoveIf(CategoriesGallery.Selected.CategoryId)

 

On the listing page, it uses the following logic:

 

SortByColumns(Filter(Products, And(CategoryId = CategoriesGallery.Selected.CategoryId,SearchBoxText.Text in ProductName)), If(category = "Reviews", "Comments", "Available"), If(category = "Reviews", Descending, Ascending))

 

 

Thanks,

 

Jonny

Anonymous
Not applicable

RemoveIf() requires a data source and a condition. Your data source is Products and your condition is a matching CategoryId. Therefor, your formula would look like this:

RemoveIf(Products,CategoryId = CategoriesGallery.Selected.CategoryId)

I'll go ahead and also say that the best practice would be to either record this item in a different "RemovedProducts" excel sheet or instead of removing it, add a column called "Active" where a value of 1 or 0 marks whether it is active. (You would then use UpdateIf() instead) That way you don't lose any data unintentionally. RemoveIf() is unforgiving in that the data will be gone if removed. 

---
If this answered your question, please click "Accept Solution". If this helped, please Thumbs Up.

Thanks @Anonymous  that's really helpful.

 

Since that removes all items from a category, is there any way to adjust so it just removes a specific product from that category? For example, how could the button remove this exact test?

 

Screen Shot 2020-01-16 at 14.51.42 (2).png

 

Thanks,

 

Jonny

 

Anonymous
Not applicable

Yes, good question. You'll need a unique ID for that item. How is the test item being displayed in your screenshot?

For example, if your gallery in your screenshot is pulled with Filter(YourData,  ItemID = Gallery1.Selected.ItemID) then you could use RemoveIf(YourData, ItemID = Gallery1.Selected.ItemID).

Hi @jonny_anything 

From your screenshot, it seems that ProductId should be the unique identifier for each row in your spreadsheet.

image.png

Since this appears to be empty for most of the records, this makes it difficult to build the condition to pass to the RemoveIf function. As an alternative, you could try the Remove function.

Remove(Products, CategoriesGallery.Selected)

This would remove the selected item in the gallery control.

 

 

 

Hi, 

 

I don't think there is a specific ProductId (screenshot below). Could it be done via selected ProductName?

 

Screen Shot 2020-01-16 at 15.25.23 (2).png

 

Thanks

 

Yes, you can use ProductName. The only thing to be careful is that if ProductName isn't unique, you can end up removing more rows than you intend.

 

RemoveIf(Products,ProductName = CategoriesGallery.Selected.ProductName)

 

Anonymous
Not applicable

@jonny_anything 

I recommend using @timl's solution above just using Remove() and referencing the record. They'll do the same thing, but if you have a product with the same name for whatever reason, they'll both be removed using the RemoveIf() and the product name.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,141)