web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Collection Merge

(0) ShareShare
ReportReport
Posted on by

Good day, 

 

I have two sharepoint lists with a bunch of data. List1 and List2. 

 

I have created a collection OnStart using

 

ClearCollect(Leavers, 'List1', 'List2');

 

List1 has a column called StaffName which is a people picker. List2 has a similar column called Name. 

 

I want to merge the columns to only show the distinct values. 

 

Alternatively, in a gallery where the Leavers collection is applied, I would like a label to show the distinct values of ThisItem.StaffName.DisplayName and ThisItem.Name.DisplayName

I have the same question (0)
  • Verified answer
    Rajkumar_M Profile Picture
    3,722 Super User 2025 Season 2 on at
    Re: Collection Merge

    Hi @JSeymour 

     

    Collect data from both lists and add a common identifier for the names.Combine the collections into one.

    Use the GroupBy function to group the data by the common identifier.

    Extract the necessary information from each group.

     

    // OnStart property of the app
    ClearCollect(
    CombinedLeavers,
    AddColumns('List1', "DisplayName", StaffName.DisplayName, "UniqueID", StaffName.Email),
    AddColumns('List2', "DisplayName", Name.DisplayName, "UniqueID", Name.Email)
    );

     

    // Group by the unique identifier (e.g., Email) and then extract other data
    ClearCollect(
    GroupedLeavers,
    GroupBy(CombinedLeavers, "UniqueID", "DisplayName", "GroupData")
    );

     

    // Now, create a collection that contains distinct names and other data
    ClearCollect(
    DistinctLeavers,
    ForAll(
    GroupedLeavers,
    {
    DisplayName: DisplayName,
    OtherData1: First(GroupData).OtherColumn1,
    OtherData2: First(GroupData).OtherColumn2
    // Add other columns as needed
    }
    )
    );

     

    // Set the gallery's Items property to the DistinctLeavers collection
    Gallery1.ItemsSource = DistinctLeavers


    In the gallery, you would then use labels with the Text property set to ThisItem.DisplayName, ThisItem.OtherData1, ThisItem.OtherData2, etc., to display the data.

     

    Note that this approach assumes that the UniqueID (in this case, the email from the People Picker field) can be used to identify distinct individuals across both lists. If this is not the case, you'll need to adjust the logic to correctly identify distinct records.

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • JSeymour Profile Picture
    on at
    Re: Collection Merge

    This worked perfectly! Thank you 🙂 

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 652 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 410 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 236

Last 30 days Overall leaderboard