cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AmitLoh-Powerap
Kudo Kingpin
Kudo Kingpin

how to remove duplicates from collection

I have a collection created with duplicate records. Distinct give me single column record which I do not want.

I just want to remove duplicate rows from collection based on one column but it should return collection again(not one column)

how to remove duplicates from collection?

1 ACCEPTED SOLUTION

Accepted Solutions
rnavarro
Regular Visitor

I found a way to remove duplicates. It is not efficient, but it works!

 

1- create a column in the collection that concatenates all values that can define the tuple as unique.

2 - create a "temporary" collection with the distinct values from this new column. 

 

ClearCollect(tempCol,Distinct(originalCollection, NEWCOLUMN));

 

3- execute a loop in this tempCol and filtering and getting the first values from the originalCollection, and storing them in a second "temporary" collection.

 

ForAll(tempCol,Collect(tempCol2,First(Filter(originalCollection , NEWCOLUMN=Result))));

 

4- Replace the originalCollection by the second "temporary" collection.

 

ClearCollect(projectLocation,tempCol2)

 

5- its done! you have a new collection with all duplicated values removed. 

 

OBS: Make sure you concatenated the correct columns in order to make the tuple unique.

View solution in original post

2 REPLIES 2
v-micsh-msft
Community Support
Community Support

Hi @AmitLoh-Powerap,

 

Thanks for the question.

Currently I can't find a way available to remove duplicate records from collection in PowerApps.

The only function that would work with the Duplicate records is Distinct function, and it will only return single columns.

We could archive the duplicate records by using GrouPBy function:

GroupBy and Ungroup functions in PowerApps

Please check to see if the groupby function could be a workaround.

In addition, please also submit an idea regarding delete the duplicate records.

Regards

 

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rnavarro
Regular Visitor

I found a way to remove duplicates. It is not efficient, but it works!

 

1- create a column in the collection that concatenates all values that can define the tuple as unique.

2 - create a "temporary" collection with the distinct values from this new column. 

 

ClearCollect(tempCol,Distinct(originalCollection, NEWCOLUMN));

 

3- execute a loop in this tempCol and filtering and getting the first values from the originalCollection, and storing them in a second "temporary" collection.

 

ForAll(tempCol,Collect(tempCol2,First(Filter(originalCollection , NEWCOLUMN=Result))));

 

4- Replace the originalCollection by the second "temporary" collection.

 

ClearCollect(projectLocation,tempCol2)

 

5- its done! you have a new collection with all duplicated values removed. 

 

OBS: Make sure you concatenated the correct columns in order to make the tuple unique.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,947)