Showing results for 
Search instead for 
Did you mean: 
Post Patron
Post Patron

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

Continued Contributor
Continued Contributor

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

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!


Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.


Super Users Coming in August

We are excited for the next Super User season.


Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!


Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,222)