cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RabidNoob
New Member

Merge Rows with Unique Values within the same table

I have a collection that has a chance of duplicating records if 1 column is filled. I have 1 column that we will call "ID" and another column that we will call "Result". A sample collection would contain [ID: 1 - Result a ], [ID: 1 - Result b ], [ID: 1 - Result c ], [ID: 2 - Result d ], [ID: 3 - Result a ]. I would like to display a gallery with Each "Result" grouped by each ID. So in this case, my gallery would be 3 rows long. ID 1 would contain a, b, c. ID 2 would contain d. and ID 3 would contain a.If I Distinct by "ID", this will cause me to lose all my "Results".  An example of what I mean is shown below from excel.

 

RabidNoob_0-1653077476133.png

 

I tried a really complex ForAll loop but turns out Powerapps cannot update variables inside of a ForAll Loop. Results is a string so I was thinking of using Concat/Concatenate, but I just end up putting all results into all IDs. This is all within PowerApps Canvas.

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

@RabidNoob 

To do this, you'd group your source collection by the ID column and Concat the results of the grouped column. The syntax would look like this:

AddColumns(
   GroupBy(colData, "ID", "GroupedData"),
   "ResultsConcat", 
   Concat(ThisRecord.GroupedData,Results & ", ")
)

 

timl_0-1653079096529.png

 

View solution in original post

2 REPLIES 2
timl
Super User
Super User

@RabidNoob 

To do this, you'd group your source collection by the ID column and Concat the results of the grouped column. The syntax would look like this:

AddColumns(
   GroupBy(colData, "ID", "GroupedData"),
   "ResultsConcat", 
   Concat(ThisRecord.GroupedData,Results & ", ")
)

 

timl_0-1653079096529.png

 

Thank you so much! I can’t believe it was this simple. 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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