cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Gottijay2000
Advocate II
Advocate II

Merge Two Records to One Record

i'm trying to combine two individual records into one record containing all the columns from each record. 

 

Example 

Set(varDogNames,{CatName: "Dog1",});
Set(varCatNames,{DogName: "Cat1"});

the result would be a record with with two fields DogName and CatName.

Any help is appreciated



 

1 ACCEPTED SOLUTION

Accepted Solutions

@RandyHayes i'm not sure if this is just me but the result of this patch only holds the first record. is this different for you?

ClearCollect(col_test,  Patch({CatName: "Dog1"}, {DogName: "Cat1"}));

View solution in original post

5 REPLIES 5
RandyHayes
Super User III
Super User III

@Gottijay2000 

 

    Patch({CatName: "Dog1"}, {DogName: "Cat1"})

 

Would give you a single record of : {CatName: "Dog1", DogName: "Cat1"}

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

@RandyHayes i'm not sure if this is just me but the result of this patch only holds the first record. is this different for you?

ClearCollect(col_test,  Patch({CatName: "Dog1"}, {DogName: "Cat1"}));

View solution in original post

timl
Super User III
Super User III

@Gottijay2000 

What @RandyHayes says is the correct approach for combining records, and I can confirm that it works.

 

timl_0-1620317701825.png

 

Apologies, error on my part. it indeed works

@Gottijay2000 

The record is {CatName: "Dog1", DogName: "Cat1"} because Patch returns records patched together as its name implies.

Putting this to a collection is a bit overkill as it is only one record.  So you will have an in-memory database table collection that has a table with one record in it, which would be the above.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (58,824)