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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Merge one collection w...
Power Apps
Answered

Merge one collection with another

(1) ShareShare
ReportReport
Posted on by

Hi all- I'm at my wit's end here.  I have looked through dozens of similar posts to follow examples of how to get two collections (or even 2 sharepoint lists) combined into a single collection.  The two collections I am working with are called:

 

DirectoryData  and

ProfileData

 

I am trying to combine into a single collection called DeepSearchData whereby the collections are matched by an email address stored in each collection as a column:

 

FCDUserEmail is the column in DirectoryData and

FCDProfileEmail is the column in ProfileData that I am matching the data sets by.

 

Can anyone help me with the syntax for this operation?

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    Hi @Anonymous 

    Is the relationship between the datasources a one-to-one or a one-to-many?

  • Verified answer
    jhall Profile Picture
    636 on at

    Assuming I start with two Collections (DirectoryData and ProfileData), I can merge them into a single table and match up entries similar to the following:

     

    ClearCollect(DirectoryData,Table({FirstName:"John",FCDUserEmail:"test@test.tst"},{FirstName:"Bob",FCDUserEmail:"test2@test.tst"}));
    ClearCollect(ProfileData,{LastName:"Smith",FCDProfileEmail:"test@test.tst"});
    ClearCollect(mergedData,AddColumns(DirectoryData,"LastName",LookUp(ProfileData,FCDUserEmail=FCDProfileEmail,LastName)))

     

    The third line creates a new Collection called mergedData, populates it w/ the contents of DirectoryData + a new column that is a LookUp from ProfileData where the values between your two email columns FCDUserEmail and FCDProfileEmail match.

  • Community Power Platform Member Profile Picture
    on at

    Thank you, that worked!

  • Community Power Platform Member Profile Picture
    on at

    It's one to one.  I guess I may have jumped the gun when I said it worked.  Is there a way to merge ALL the columns from both datasets based on the matching email column?

  • Community Power Platform Member Profile Picture
    on at

    It's one to one.  I guess I may have jumped the gun when I said it worked.  Is there a way to merge ALL the columns from both datasets based on the matching email column?

  • jhall Profile Picture
    636 on at

    Now ask me how to do this if the two "lookup" columns were identically named.  Smiley LOL

     

    HINT: Try the RenameColumns() function on your LookUp table input.

  • jhall Profile Picture
    636 on at

    Yes.  It's just adding some additional items to the LookUp.  The first item you add to the mergedList adds ALL COLUMNS from that table.  The LookUp then can add all of the columns from the secondary table.  You'd need to list them out though.  Let me pull up the LookUp function to make sure I've got the formatting correct and I'll post a followup.

  • jhall Profile Picture
    636 on at

    Yeah, it does get a little hairy w/ this as the solution.  It really depends on the use case of if this is a good way to handle it.  So if we stick w/ what I provided, then you pick the largest of the two Tables/Collections per field count and do that first (List1 in the example below).  Then add on each additional field manually into the list similarly to the blue text below.

     

    This could get nasty fast, but there isn't a simple JOIN function within PowerApps (to my knowledge).  Kinda where maybe a SQL View or similar is a better solution to do outside of the application.

     

    ClearCollect(
        mergedList,
        AddColumns(
            List1,
            "LastName",
            LookUp(
                List2,
                Email = Email2,
                LastName
            ),
           "NextField",
           LookUp(
                List2,
                Email = Email2,
                NextField
            )
        )
    )

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard