cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FinePilsner
Level: Powered On

Duplicate a collection, changing values in one column

Situation: I have Collection1 with several rows/columns:

ID | Group | Date

01 | ABCDE | <blank>

02 | FGHIJ | <blank>

03 | KLMNO | <blank>

 

I eventually need to write this data back to a SharePoint list, but before doing so, I need to change all the records in the collection to today's date. However for display purposes in the PowerApp I need to leave Collection1 alone, so I need to create a new Collection2 with this change:

ID | Group | Date

01 | ABCDE | 07/31/2019

02 | FGHIJ | 07/31/2019

03 | KLMNO | 07/31/2019

 

I've been messing around with ClearCollect, ForAll, Patch, Update and can't get this right!

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Duplicate a collection, changing values in one column

@FinePilsner

 

col1 - your original collection

col2 - your new collection

 

ClearCollect(col2, col1);UpdateIf(col2,IsBlank(col2[@Date]),{Date:Today()})

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

View solution in original post

2 REPLIES 2
Super User
Super User

Re: Duplicate a collection, changing values in one column

@FinePilsner

 

col1 - your original collection

col2 - your new collection

 

ClearCollect(col2, col1);UpdateIf(col2,IsBlank(col2[@Date]),{Date:Today()})

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

View solution in original post

Highlighted
FinePilsner
Level: Powered On

Re: Duplicate a collection, changing values in one column

@RezaDorrani -- excellent once again...

 

I actually need to overwrite non-blank values as well, so what I used was this:

ClearCollect(col2, col1);UpdateIf(col2,true,{Date:Today()})

This seems like a slight misuse of UpdateIf but it's working perfectly anyway! Thanks again!!

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

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