cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AlexandrePicque
Helper I
Helper I

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

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
RandyHayes
Super User
Super User

@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 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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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

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

@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 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

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,288)