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

Using 'Remove' for a table (not a Collection) and from a ForAll Loop of another table

I want to 'delete' records in table2 

if they are found in table1

PowerApps complains that Table2 is not a Collection

 

Here is the code;

 

ForAll(Table1,
Remove(Table2,First(Filter(Table2,Table2_ID=Table1_ID)))
);

 

 

4 REPLIES 4
KyleJ
Helper II
Helper II

Why not make it a collection? 

RandyHayes
Super User III
Super User III

@Ritoxik 

Please consider changing your Formula to the following:

ForAll(Table1,
   RemoveIf(Table2, Table2_ID=Table1_ID)
);

This should give you what you want.

 

I hope this is helpful for you. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I did try that too, but still complaining that it should be a Collection

* What I finally did is to change the Table2 into a Collection, and kept only Table1 as a Table

 Thus Remote & RemoteIf seems to work only on Collection, but in the PowerApps Documentation it says "data source" Tables & Collections...

 

Now I will try again on an empty test App to see if your statement works, just to make sure it is nothing wrong on my App that give that error message with Collection required

 

RandyHayes
Super User III
Super User III

@Ritoxik 

A collection is not required.  This can be a datasource and we use this formula ALL the time without issue.

Make sure you don't have some other item in your App that is called Table2 - check your Variables and Collections to make sure you are actually dealing with the datasource and not something else.

 

EDIT: Oh and I do assume you are using pseudo names in your examples as there are other factors involved if you are trying to use that exact formula.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,043)