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 two collection t...
Power Apps
Unanswered

Merge two collection to another collection

(0) ShareShare
ReportReport
Posted on by

So I have three collection

 

So Collection A will have a choice column from a SP List.  

Collection B is collection I generated from this SP List, 

 

So Collection C, I want to put all the records in Collection A and Collection B to this one. But doing so result with an error for the Collection B Choice column.

 

ClearCollect(
CollectionA,
{
SourceName: "",
SourcePort: "",
SourceServiceType: "",
ServerName: "",
DestinationPort: "",
DestinationServiceType: "",
});


ClearCollect(CollectionB,
AddColumns(ShowColumns
(Filter(SPList,MasterID = galID),
"ID","MasterID","SourceName","SourcePort","SourceServiceType","ServerName","DestinationPort","DestServerType"),"ColID",ID));

Collect(CollectionC,
ShowColumns(RenameColumns(CollectionB,"DestServerType","DestinationServiceType"),"SourceName","SourcePort","ServerName","DestinationPort"),
ShowColumns(CollectionA,"SourceName","SourcePort","SourceServiceType" ,"ServerName","DestinationPort","DestinationServiceType") );

 

So when I try to add the choice columns of CollectionB I get the below error and also when I try to use the DropColumns on CollectionB

indhaa_0-1625504570637.png

 

Choice Column of CollectionA and CollectionB are patch as below

indhaa_4-1625506851930.png

 

indhaa_2-1625506754495.png

indhaa_1-1625506651696.png

I will be adding each records from both Collection A and B as a separate record to Collection C. 

Let me know what I'm doing wrong

 

 

 

Categories:
I have the same question (0)
  • indhaa Profile Picture
    on at

    @WarrenBelz can help?

  • indhaa Profile Picture
    on at

    Hi can I get some help on this . Couldn't finish the App due to this. @CNT 

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @indhaa I'm not able to follow your column names as they are a bit confusing. I'll give you an example of combining Collections. Try to follow this pattern. Hope it helps!

    ClearCollect(colComb1, {Name:"Tom",ID:1}, {Name:"Mark",ID:2});
    ClearCollect(colComb2, {Name:"Tom", Score:10, Rank:1}, {Name:"Tom", Score:20, Rank:3},{Name:"Mark", Score:15, Rank:2},{Name:"Mark", Score:25, Rank:4});
    ClearCollect(colComb3, AddColumns(colComb2, "ID", LookUp(colComb1 As tempColComb1, Name=tempColComb1.Name).ID))

     

  • indhaa Profile Picture
    on at

    Hi

     

    Sorry about that. So what I trying to achieve is a Repeating table like in SharePoint. So I have two SharePoint List. So when a user submit a form it will update the two SP List. So the main SP list, I'm using Concat to combined all the records to a multi line of text columns. The other SP List will have these records. Hope you get what I'm trying to achieve.

     

    I'm referring to second SP List as a gallery in my Form. So when in Edit Mode. I'm trying to combine the changes to the Main SP List in Concat and Update the records and Add any new records to the second SP List. 

    So that's why I'm using Collection C, to Concat the new changes and the new records, So Collection C wont need a lookup since each record from Collection A and Collection B will be different.

     

    I have been able to achieve the same concept on another form but I think since I'm dealing with Choice column I'm having the issue. 

     

    As you can see the Collection B is collection created from second SP List and the column that I'm having issue is showing as a table. I think that is causing the issue. Collection A is referring to the same SP List choice column 

    indhaa_0-1625655173093.png

    If this cannot be corrected, I thinking of using the Collection A and Collection B on my concat code. But new to concat and the code was provided by the community too. Let me know




  • indhaa Profile Picture
    on at

    So I will add with few columns.

    ClearCollect(
    CollectionA,
    {

    ServerName: "",
    DestinationServiceType: "",
    });


    ClearCollect(CollectionB,
    AddColumns(ShowColumns
    (Filter(SPList,MasterID = galID),
    "ID","MasterID","ServerName","DestServerType"),"ColID",ID));

    Collect(CollectionC,
    ShowColumns(RenameColumns(CollectionB,"DestServerType","DestinationServiceType"),

                                                         "ServerName","DestinationServiceType "),
    ShowColumns(CollectionA, ,"ServerName","DestinationServiceType") );

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @indhaa I'm not quiet sure if you need to use so many collections to do this. Anyway, I'll just concentrate on the issue with the Choice Column.
    If I understand it right, you want the DestServerType in Collection B to be the matching Choice value from Collection A and not a Table as it is now. For that you have to do a LookUp to Collection A to find the matching value.

  • indhaa Profile Picture
    on at

    Hi.

     

    I might be doing it wrong with too many collections. But this is what I thought would work for me without providing too much code during the New and Edit Form mode and I'm doing differently than what is provided in the video too. https://www.youtube.com/watch?v=DylxsXIUyDc

     

    I am using the same Gallery for my New , Edit and View request.  But I created separate collection since I need to know if the request is New or Change. 

     
    So Collection A will contain new records and Collection B will contain the records from SP List.
    So during Form New mode I will be using Collection A only to Patch SP List 2 as a new record. 
    During Form Edit mode will be using Collection B to update SP List 2 and Collection A (if new records to Patch as a new record to SP List 2). There is no relation between Collection A and Collection B. The Only relation will be with SP List 1 (which contain Concat records of SP2) and SP List 2.

     

    Hope not confusing you.. If not maybe I need to forget about merging ALL the records in Collection A and Collection B to  Collection C  and ask for help to Concat the collection in my code. 
    Can continue in this thread or need to create a new thread for that

     

     

     

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @indhaa Let me give you a tip on how I would do repeating details with this example (An Employee TimeSheet),

    SP List Employee Main: columns EmployeeID & Name

    SP List Employee TimeSheet: columns EmployeeID (LookUp to the EmployeeID column in the Main List) & InTime, OutTime

     

    In The Canvas App, I'll have an EditForm with Datasource as 'SP List Employee Main'. Here a new Employee can be added or an existing Employees details can be modified. In the Submit Buton, I'll just say, SubmitForm(myEmployeeForm).

     

    To Record the Timesheet (more than one record for an Employee), I'll have a Gallery with two DatePickers (one for InTime and the other for OutTime).

    I'll create a collection and load the currently selected Employees TimeSheet details into it (if there is any). I'll have one extra column (recordtype) in the collection to show if this is a New Record or Existing record. I'll set the recordtype to Edit for all these records (as they re already there).

    I'll set the Items property of the Gallery to this collection and the inTime and OutTime DatePickers to the values of the corresponding columns.

    When the user wants to add a new time sheet entry, I'll add a new record to the Collection (using Patch) and set the recordtype to New.

     

    When the user hits submit, I'll go trough this collection using a ForAll and If the recordtype is Edit, I'll use Patch to update that record. If the recordtype is New, I'll create a new record.

     

    Hope this helps!

  • indhaa Profile Picture
    on at

    Thanks a lot

    The difference between an amateur and an expert. I will try as above and will let you if I need any help

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @indhaa Glad to help!

     

    Please remember to give a 👍 and accept the solution as it will help others in the future.

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 759 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 310 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 228

Last 30 days Overall leaderboard