In Power Apps, you can merge two collections using the ClearCollect
function along with the AddColumns
function if you want to add additional columns from one collection to another. Here’s a basic example:
Let’s say you have two collections named Collection1
and Collection2
, and you want to merge them into a new collection named MergedCollection
.
This code will clear the MergedCollection
and then add all the records from Collection1
followed by adding all the records from Collection2
into MergedCollection
.
PowerAppsCopy code
ClearCollect(MergedCollection, Collection1);
Collect(MergedCollection, Collection2)
If you want to add additional columns from Collection2
to Collection1
, you can use the AddColumns
function:
PowerAppsCopy code
ClearCollect(MergedCollection, AddColumns(Collection1, "AdditionalColumn1", Collection2[@AdditionalColumn1], "AdditionalColumn2", Collection2[@AdditionalColumn2], ...))
Replace "AdditionalColumn1"
, "AdditionalColumn2"
, etc., with the actual column names you want to add from Collection2
to Collection1
.
Remember to adjust the column names and structures according to your actual collections.