What is the best method to merge these two collections and retain ALL columns? The two collections are joined via the deal id which is "Title" in colDashDealIntakeApp and "Deal_x002d_Ref_x002d_ID" in colDashDealUpdates.
ClearCollect(colDashDealIntakeApp, ShowColumns('Deal-Intake-App', "Title", "Close_x002d_Date"));
ClearCollect(colDashDealUpdates, ShowColumns('Deal-Updates', "Deal_x002d_Ref_x002d_ID", "Pursuit_x002d_Closedown_x002d_Da"));
Solved! Go to Solution.
The principle behind merging the collections is to use the AddColumns() function to create a new column in one of the collections. So starting with the first collection, first you give the new added column a "name", then you use Lookup() on the second collection to match the common fields, and then select the column in the second collection that you want to add to the first collection. The syntax is
AddColumns( Table, "ColumnName1", Formula1 [, "ColumnName2", Formula2, ... ] )
where in your case, the table is a collection, the second element is a new name you will give to the added column and the formula is a Lookup(Table2, Deal-ID=Title, PCDDate) which looks up in a second collection for a row that matches the dealID to the title, and then adds the column from the second table.
It appears that you are using SharePoint and I suggest that you review https://www.practicalpowerapps.com/data/constructing-your-first-power-app-before-you-start/
The way you have constructed your lists makes it extremely difficult to work with them.
You could use the AddColumns() function to create the final merged collection
ClearCollect(colDashDealIntakeApp, ShowColumns('Deal-Intake-App', "Title", "Close_x002d_Date"));
ClearCollect(colDashDealUpdates, ShowColumns('Deal-Updates', "Deal_x002d_Ref_x002d_ID", "Pursuit_x002d_Closedown_x002d_Da"));
With({cddia:colDashDealIntakeApp,
cddu:colDashDealUpdates,
dealID:"Deal_x002d_Ref_x002d_ID",
pursuitclosed:"Pursuit_x002d_Closedown_x002d_Da"},
ClearCollect(
colAll,AddColumns(
cddia,"DealUpdates", Lookup(
cddu,dealID = "Title",'Deal-Updates'
),
"PursuitCloseDown", Lookup(
cddu,"dealID= "Title",pursuitclosed
)
)
)
)
This assumes that the first two collections actually exist. The merged collection would be colAll. The With() function is used to clean up your collection names and fields.
@Drrickryp - Thanks for the response. Unfortunately, AddColumns has some invalid code. Any recommendations?
My code makes assumptions about your collections. I revised it to try to make it less likely to have typos. However, could you put a couple of datatables on a screen and set the Items property to the two collections you are trying to merge so that I can get a better idea about your data?
This what the data looks like. The bold header text is not the actual col names. "PCDate" = "Pursuit_x002d_Closedown_x002d_Da".
The principle behind merging the collections is to use the AddColumns() function to create a new column in one of the collections. So starting with the first collection, first you give the new added column a "name", then you use Lookup() on the second collection to match the common fields, and then select the column in the second collection that you want to add to the first collection. The syntax is
AddColumns( Table, "ColumnName1", Formula1 [, "ColumnName2", Formula2, ... ] )
where in your case, the table is a collection, the second element is a new name you will give to the added column and the formula is a Lookup(Table2, Deal-ID=Title, PCDDate) which looks up in a second collection for a row that matches the dealID to the title, and then adds the column from the second table.
It appears that you are using SharePoint and I suggest that you review https://www.practicalpowerapps.com/data/constructing-your-first-power-app-before-you-start/
The way you have constructed your lists makes it extremely difficult to work with them.
@Drrickryp - Thanks for the great explanation of merging collections! I agree about my mistake with the column names.
It looks like you edited your original proposed solution so I ran the updated version. I am getting error "AddColumns has some invalid arguments". It looks like you are using aliases to make references easier. Any recommendations on how to fix this are greatly appreciated.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
200 | |
52 | |
41 | |
39 | |
35 |
User | Count |
---|---|
261 | |
85 | |
71 | |
69 | |
66 |