cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User III
Super User III

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
Highlighted
Dual Super User III
Dual Super User III

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

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

Highlighted
Dual Super User III
Dual Super User III

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.
Highlighted
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
Community Conference

Power Platform Community Conference

Find your favorite faces from the community presenting at the Power Platform Community Conference!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,680)