PowerApps - Merge Two Collections in to one Collection
In PowerApps, we can merge two collections in to one collection based on the unique value in the two collection. I had a requirement to merge two collections format as below,
Employee Unplanned Leaves Data List - Collection 1
Employee ID
Employee Name
Employee Leave Date
Employee Leave Applied Date
Employee Unplanned Leaves
Employee Planned Leaves Data List - Collection 2
Employee ID
Employee Name
Employee Leave Date
Employee Leave Applied Date
Employee Planed Leaves
These are two different collection and we need to merge these two items based on the employee id. I have used following formula to merge the collections
ClearCollect(
OutputCollection,
Collect(
AddColumns(
collection1,
"Employee Planned Leave",
LookUp(collection2,EmployeeID=collection1[@EmployeeID],Employee Planned leave),
"Employee Planned Leave Date",
LookUp(collection2,EmployeeID=collection1[@EmployeeID],Employee Planned Leave Date)
),
Filter(collection2,Not(EmployeeID in collection1.EmployeeID)),
)
)
Here I am using two collection and getting the values into collection1
Get the matched Items
Get Non Matched Items.
Matched Items will be added to the respective records and Employee Planned Leave and Employee Planned Leave Date. Un0-Matched items will be added as separate records in Planned and Un-planned leave collections,
Comments