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

Removing from Collection if exists in another collection

Hello,

I have two collections, PlannedVisits and CompletedVisits. What I want to do is remove the visit from the PlannedVisits collection if the visit is in the CompletedVisits collection. Both Collections will have VisitID and LineNumber columns.

 

I've tried using a ForAll on the PlannedVisits collection and then Filter the CompletedVisits collection and tried a RemoveIf with a filter in the condition, with no success.

 

 

I will really appreciate if anyone can let me know how to do this.

 

Thank you 

1 ACCEPTED SOLUTION

Accepted Solutions
RicHague
Frequent Visitor

I think I have worked this out. I can use the ClearCollect to a temporary collection with a filter:

 

ClearCollect(
    colTemp1,
    Filter(
        colPlannedVisits,
        !(VisitID in colCompletedVisits.VisitID And LINENUM in colCompletedVisits.LINENUM)
    )
);
ClearCollect(colPlannedVisits,colTemp1);
Clear(colTemp1);

 

This copies the visits that are not in the CompledtedVisits collection. So the visits that are in the both are not copied.

View solution in original post

1 REPLY 1
RicHague
Frequent Visitor

I think I have worked this out. I can use the ClearCollect to a temporary collection with a filter:

 

ClearCollect(
    colTemp1,
    Filter(
        colPlannedVisits,
        !(VisitID in colCompletedVisits.VisitID And LINENUM in colCompletedVisits.LINENUM)
    )
);
ClearCollect(colPlannedVisits,colTemp1);
Clear(colTemp1);

 

This copies the visits that are not in the CompledtedVisits collection. So the visits that are in the both are not copied.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (3,355)