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

Update the collection according to an element of it

Hello,

 

UpdateCollection.PNGAs you can see in the screenshot, the ID_COL column has a value different from the lines below. However, they have the same value for the ID_GI column.

 

What I want to do seems logical but I can not ..

For all values ​​identical to the column ID_GI, I would like to update these lines to have the ID_COL value of the first line on the following and make this for the rest of the collection.

 

Do you have an idea for doing this?

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Update the collection according to an element of it

Hi @AlexandrePicque ,

Do you want to update the value of ID_COL field to the first value when the  ID_GI value is same?

I've made a similar test:

1) ClearCollect(test1,GroupBy(collection1,"name2","test"))

2)ClearCollect(test2,Ungroup(AddColumns(test1,"name3",First(Split(Concat(test,name1&","),",")).Result),"test"))

Then, name3 is the changed field.

On your side, you ould try this:

1) 

ClearCollect(test1,GroupBy(collection1,"ID_GI","test"))   ///group based on ID_GI

2)

ClearCollect(test2,Ungroup(
                           AddColumns(
                                      test1,"ID_COL2",         
                                      First(Split(Concat(test,ID_COL&","),",")
                                           ).Result           //get the first value of ID_COL
                                       ),
                            "test"                     //add one column that have the same value based on groupedID_GI
                           )
              )

Best regards,

Community Support Team _ Phoebe Liu

 

 

Community Support Team _ Phoebe Liu
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

4 REPLIES 4
Super User
Super User

Re: Update the collection according to an element of it

@AlexandrePicque 

Can you provide a little more detail about what you expect the results to be based on your picture of the data?

Perhaps a mock-up of the results you expect from that picture.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
AlexandrePicque
Level: Powered On

Re: Update the collection according to an element of it

Of course !

 

For all the lines of the collection having the same ID_GI (Column of right on the image), I want to modify their value ID_COL (Column of left on the image) and to replace it with the value ID_COL of the first line with the same ID_GI value.

 

It's pretty hard to explain, so I annotated the picture if it helps.

 

screenArrow.PNG

Community Support Team
Community Support Team

Re: Update the collection according to an element of it

Hi @AlexandrePicque ,

Do you want to update the value of ID_COL field to the first value when the  ID_GI value is same?

I've made a similar test:

1) ClearCollect(test1,GroupBy(collection1,"name2","test"))

2)ClearCollect(test2,Ungroup(AddColumns(test1,"name3",First(Split(Concat(test,name1&","),",")).Result),"test"))

Then, name3 is the changed field.

On your side, you ould try this:

1) 

ClearCollect(test1,GroupBy(collection1,"ID_GI","test"))   ///group based on ID_GI

2)

ClearCollect(test2,Ungroup(
                           AddColumns(
                                      test1,"ID_COL2",         
                                      First(Split(Concat(test,ID_COL&","),",")
                                           ).Result           //get the first value of ID_COL
                                       ),
                            "test"                     //add one column that have the same value based on groupedID_GI
                           )
              )

Best regards,

Community Support Team _ Phoebe Liu

 

 

Community Support Team _ Phoebe Liu
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

Super User
Super User

Re: Update the collection according to an element of it

@AlexandrePicque 

The picture makes it much clearer - thanks!

 

So, you stated that you wanted to change the values in the original collection based on the criteria you mentioned.  So, the formula you will want for that will be:

ForAll(
    GroupBy(RenameColumns(yourCollection, "ID_GI", "GI_ID"), "GI_ID", "rows"), 
    UpdateIf(yourCollection, ID_GI=GI_ID, {ID_COL:First(rows).ID_COL})
)

This will provide what you want without having to create a bunch of other collections to do it.

AlexandrePicque.png

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

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: 98 members 4,812 guests
Please welcome our newest community members: