Showing results for 
Search instead for 
Did you mean: 
Level 8

Consolidate (Merge Record) Data into a Collection from Local "LoadData" File

the following statement works great. It loads data into a Parts table from a database object. Those items from the database are marked as "Saved",  and then loads data from a local table, and those were previously noted as "Changed".


Here is the code:





This works, but the issue is that there are in some cases duplicate rows: Saved and Changed. There could be more "Changed" rows than saved rows, and those are ok. But if there is a Saved Row and a Changed Row with the Same RowId, then those two rows need to be merged into only one row, with the values from the "Changed" superseding those in the "Saved" row.


Not certain how to modify the above code to accomplish this.


Help is much appreciated.


Thank you

Level 8

Re: Consolidate (Merge Record) Data into a Collection from Local "LoadData" File

Hi @vsslasd


You could theoretically filter the list using the First or Last Function's if the data is in a logical format. I.E. if the Duplicates always go Saved then Changed in the order of the list (You could also maybe sort the List By ID and then Status to give you the correct format for this) After this using Last() to pickup the Second Duplicate will give you a clean list. 


If not its a bit more complicated. You could maybe do a clean up job first, using distinct() on the PartsLocal collection, to get a list of ID's and removeif() to clean these out of the Parts collection before you Load the data.


A bit complicated but there isn't much duplicate correction in Powerapps just now.


Hope this helps,


Helpful resources


Power Apps Super User Class of 2020

Check it out!


New Badges

Check it out!


Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,641)