Skip to main content
Community site session details

Community site session details

Session Id : ir7/7RIpgYA8WK9sxhlGEM
Power Apps - Building Power Apps
Answered

How to remove duplicates from two different collections?

Like (0) ShareShare
ReportReport
Posted on 7 Sep 2023 18:59:00 by 30

I'm really racking my brain on how to figure this out. I have a few collections that retrieve teams meeting data from. The one collection stores the attendees to the meetings and displays this information within a gallery. When someone selects one of the attendees it sends the info to a SharePoint folder. I then have a sign-out page with a gallery that shows the "signed in users" and updates the SharePoint with the information. My problem is I have no way to remove the attendees from the collection after they have signed in. I need to iterate through the name column of both collections and if a match is found only remove it from the attendee collection as that's the one that's displaying the data

 

Any help is greatly appreciate thank you!

  • Michael E. Gernaey Profile Picture
    45,440 Super User 2025 Season 2 on 08 Sep 2023 at 16:19:45
    Re: How to remove duplicates from two different collections?

    No worries and glad I could help.

  • lmmcrac2004 Profile Picture
    30 on 08 Sep 2023 at 16:18:33
    Re: How to remove duplicates from two different collections?

    Mike thank you so much you have saved me thank you for dealing with my stupidity 

  • Verified answer
    Michael E. Gernaey Profile Picture
    45,440 Super User 2025 Season 2 on 08 Sep 2023 at 16:12:05
    Re: How to remove duplicates from two different collections?

     

    Actually let me make it simpler

     

    this example loops through all items in Gallery1 and removes values from a collection if the VisitorName value in the collection is equal to the current item in the loop ThisRecord.VisitorName

     

     

     

    ForAll(Gallery1.AllItems,
     RemoveIf(CollectValues, VisitorName = ThisRecord.VisitorName);
    );

     

    please note I am answering based on what you typed.

     

    now you just one a single loop and it will remove if it exists.. if not it does nothing and you dont need to loop  through the second at all

  • lmmcrac2004 Profile Picture
    30 on 08 Sep 2023 at 16:02:04
    Re: How to remove duplicates from two different collections?

    This is a really good idea I'm trying to implement this now and just a little confused

    lmmcrac2004_0-1694188826377.png

    So on true (meaning is found a match) I want to remove that value from the collection connected to the gallery, what am I doing wrong? 

     

  • Michael E. Gernaey Profile Picture
    45,440 Super User 2025 Season 2 on 08 Sep 2023 at 15:48:04
    Re: How to remove duplicates from two different collections?

    Yes, you would need unfortunately though do a double loop or you can do a single loop (outer) and do a lookup against the AllItems in the second. Either way it would do what you just asked.

     

     

    // Two Galleries, I aliased them as A and B
    // Then since its a copy and paste you can see Title1 and Title1_1 where i compare the text
    // you compare whatever you want
    ForAll(Gallery1.AllItems As A,
     ForAll(Gallery2.AllItems As B,
     If(A.Title1.Text = B.Title1_1.Text, true, false);
     // do whatever you are gonna do in the If above
     )
    )

     

     

    but I cannot tell if you are already doing this or not. But thats one way to do this.

     

    Cheers,

    -Michael

     

    Please Kudo or Select as Answer if it helps or solves your issue

  • lmmcrac2004 Profile Picture
    30 on 08 Sep 2023 at 15:42:03
    Re: How to remove duplicates from two different collections?

    I was just trying to explore my options. What I have working is this function: RemoveIf(CollectValues, VisitorName = SignOutGalleryNew.Selected.Title). Which removes the matched name from the Collection with the name if its present within the sign outlist. Obviously the problem is its only gonna just remove the default selection of the sign out list so having over 1 name breaks it. Is there a way to iterate through the gallery items so it compares the VisitorName in the collection to those in the sign out list? 

  • Michael E. Gernaey Profile Picture
    45,440 Super User 2025 Season 2 on 08 Sep 2023 at 15:23:11
    Re: How to remove duplicates from two different collections?

    There is no compare of 2 galleries. What would it compare?

     

    You have to provide to glue in between since you are the one defining the incoming Items values.

     

    And in your case you are saying its based on a SharePoint list, but you cannot remove an item from a Gallery that is based on a list unless you modify the list to no longer have that.

     

    What you want isn't hard, but your looking for an easy button, I couldn't easy button it any better in C/C++ or C# directly.

     

    You can use the AllItems property to validate if things exist in each, but you said remove them, thats a different story.

     

     

     

  • lmmcrac2004 Profile Picture
    30 on 08 Sep 2023 at 14:50:34
    Re: How to remove duplicates from two different collections?

    Yeah I like this idea just the implementation seems hard like realistically I want to just be able to compare the SignIn gallery to the signout gallery and filter it that way but no matter what I do that isn't working. I think its because the signin gallery is based off a collection where the signout is based off a sharepoint list. Regardless, i feel very defeated lol 

  • uwenagel Profile Picture
    382 on 08 Sep 2023 at 14:00:23
    Re: How to remove duplicates from two different collections?

    You can always recalculate your collection after you remove one of the elements.

     

    If you have an attribute say 'SignedIn' that can have 'Yes' or 'No' then you would show in your first collection only the ones that have 'SignedIn' = 'No'.

     

    Then when you select one entry in order to sign in you set the attribute to 'Yes' and recollect your collection.

     

    The second gallery only shows the ones from a second collection filtered with 'SignedIn' = 'Yes'. So you have to recalculate this collection as well upon signing out from the first gallery.

     

    You have to again recalculate both collections when you sign out one of the entries from the second gallery (set 'SignedIn' to 'No' again).

     

    The problem still is, how to trigger a recalculation of the galleries when an entry is made from another action (real time).

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

  • vaubeee Profile Picture
    533 on 08 Sep 2023 at 13:38:47
    Re: How to remove duplicates from two different collections?

    Tricky 😉
    Maybe you have to separate the invited attendees (= realtime Teams data) from the users who have actually "Signed in" from your app.

    Keep the functionality to update to "Signed in" (in "real time" collection) onSelect of SignIn-Button

    Add another datasource/collection and separately store attendees who sign in there.

    Use this new collection as reference for your sign out gallery

    Remove them from the new collection, when they sign out and update their status to Signed Out (in "real time" collection)

     

    ------------------------------------------------------------------------------------------------------------------------------
    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Loading complete