cancel
Showing results for
Did you mean:
Level: Powered On

## Using a Loop to delete records from a Local List

Here is the situation:

Let us consider Table_A (a table coming from Excel), containing several columns, the most important one being the column ID, this table contains several records.
Now, let us consider the local collection Collec_B, created at app launch and also containing the column ID and several records.

I am looking for a way to loop through Collec_B and delete any record that has a matching ID with any of the records in Table_A.
I thought using ForAll would be a good start, but it seems using the Remove function inside isn't allowed. Also I can't do it "manually" since both these tables change regularily.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User

## Re: Using a Loop to delete records from a Local List

Another option to consider is just using the RemoveIf function.

Try changing your formula to this:

RemoveIf(Collec_B, ID in (Table_A.ID))

This will remove any records in Collec_B that have an ID equal to any ID in Table_A.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
5 REPLIES 5
Super User

## Re: Using a Loop to delete records from a Local List

Can you duplicate just the ID's in Collec_B to another table or collection?  Then do a ForAll on that collection and do a remove from Collec_B by looking up the ID in the temp table with the records in Collec_B when you find a matching record in Table A

-------------------------------------------------------------------------
If you like my response, please give it a Thumbs Up.
Level: Powered On

## Re: Using a Loop to delete records from a Local List

This would be a work around.
Could you also help me on the overall logic to actually look for any matching record ?

As of now I have this formula:

```ForAll (Collec_B_Bis;
If (ID = LookUp(Table_A; ID=ID).ID);
Remove (Collec_B; ID = LookUp (Table_A; ID = ID))
)
)```
Highlighted
Super User

## Re: Using a Loop to delete records from a Local List

Another option to consider is just using the RemoveIf function.

Try changing your formula to this:

RemoveIf(Collec_B, ID in (Table_A.ID))

This will remove any records in Collec_B that have an ID equal to any ID in Table_A.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User

## Re: Using a Loop to delete records from a Local List

I actually like @RandyHayes solution below better.  Give that one a try.

-------------------------------------------------------------------------
If you like my response, please give it a Thumbs Up.
Level: Powered On

## Re: Using a Loop to delete records from a Local List

Oops, forgot to reply. It indeed worked. Much thanks to both you and @Pstork1 for helping me.

Announcements

#### Watch Sessions On Demand!

Continue your learning in our online communities.

#### Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

#### Power Platform World Tour

Coming to a city near you

#### PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

#### Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

#### Power Platform Summit North America

Register by September 5 to save \$200

Top Kudoed Authors
Users Online
Currently online: 88 members 4,390 guests
Recent signins: