cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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.

 

Thank you for reading

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

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

@Anonymous 

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.

 

I hope that is helpful.

_____________________________________________________________________________________
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.

View solution in original post

5 REPLIES 5
Super User
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 I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Anonymous
Not applicable

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))
      )
)
Super User
Super User

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

@Anonymous 

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.

 

I hope that is helpful.

_____________________________________________________________________________________
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.

View solution in original post

Super User
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 I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

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.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

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

Top Kudoed Authors
Users Online
Currently online: 62 members 3,516 guests
Please welcome our newest community members: