cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
vsslasd
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:

ClearCollect(Parts,

(AddColumns('[dbo].[vwParts]',"Status","Saved"),

LoadData(Parts,"PartsLocal",true));

 

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

1 REPLY 1
OneThing
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,

Nicky

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 198 members 5,782 guests
Please welcome our newest community members: