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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to join 2 tables (...
Power Apps
Answered

How to join 2 tables (SP lists) into single collection?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I have 2 SP lists as below:

 

StaffContact:

Name

Phone

 

EmployeeContact:

Username

Tel

Fax

 

The 'Name' and 'Username' fields are both text field and describe the same thing. I need them merge together into same column. 'Phone'='Tel', too. StaffContact do not have 'Fax' field but I want the merged collection have column 'Fax' with empty content.

 

I tried to build a collection but keep getting error in PowerApp Studio. Could you please advise? Here is my code I put in App.OnStart:

 

ClearCollect(
 MergedCollect,
 ShowColumns(
 AddColumns('StaffContact', "User", Name),
 "Phone","Fax"));
Collect(
 MergedCollect,
 ShowColumns(
 AddColumns('EmployeeContact', "User", Username),
	AddColumns('EmployeeContact', "Phone", Tel),
 "User","Phone","Fax"));
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Hi @Anonymous ,

    Not sure this is exactly what you want as I cannot see your data, but it would be something like this

    ClearCollect(
     MergedCollect,
     ShowColumns(
     AddColumns(
     'StaffContact', 
     "User", 
     Name,
     "Fax",
     ""
     ),
     "User",
     "Phone",
     "Fax"
     )
    );
    ForAll(
     'EmployeeContact',
     Patch(
     MergedCollect,
     {User:UserName},
     {Phone:Tel}
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Studio is prompting me "Name isn't valid. This identifier isn't recognized" for 2nd line of code 

    ClearCollect(
     MergedCollect,

    I look into some old discussion, saying I must define at least one column in the syntax. But in your code sample, I think "ShowColumns ...." part have already done this part.

    What's the problem? 

     

    I have tried add below line at the top:

    ClearCollect(MergedCollect,{User:"",Phone:"",Fax:""});

    There will be no more syntax error . However my collection is empty.

  • WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    @Anonymous ,

    My post was free-typed, so you have to look a bit on the structure - try it now - there was an extra comma.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for your response. May I clarify that 2nd part:

     

    ForAll(
     'EmployeeContact',
     Patch(
     MergedCollect,
     {User:UserName},
     {Phone:Tel}
     )
    )

     

    Is it means "for each of record in EmployeeContact, INSERT into MergedCollect with structure EmployeeContact.Username as User, EmployeeContact.Tel as Phone"?

    After your update, there is no more syntax error. But MergedCollect only contain last row of EmployeeContact (it has 60 rows).

  • WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Hi @Anonymous ,

    I cannot see your data or wherever you values are, but the structure assumes that you have the same name in User as you do in UserName (for the match of records) and then inserts the Tel value in StaffContact into the field Phone in the new collection. All the values are coming from StaffContact and it was not clear in your post what was coming from the other list.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Ah, I am very sorry. My bad. StaffContact & EmployeeContact are 2 lists from different departments. Therefore there are no relationship between them. StaffContact has 10 rows while EmployeeContact have 60 rows. I want to merge them into one collection with 70 rows.

  • Verified answer
    WarrenBelz Profile Picture
    154,399 Most Valuable Professional on at

    Hi @Anonymous ,

    Try this

    ClearCollect(
     MergedCollect,
     ShowColumns(
     AddColumns(
     RenameColumns(
     'StaffContact',
     "Phone",
     "Tel",
     "Name",		
     "UserName"
     ), 
     "Fax",
     ""
     ),
     "UserName",
     "Tel",
     "Fax"
     )
    );
    Collect(
     MergedCollect
     'EmployeeContact'
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 94

#2
WarrenBelz Profile Picture

WarrenBelz 82 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 38 Super User 2026 Season 1

Last 30 days Overall leaderboard