web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Powerapps - Searching ...
Power Apps
Answered

Powerapps - Searching for duplicate fields in a Collection

(0) ShareShare
ReportReport
Posted on by 23

In Power Automate, I am importing rows from excel into powerapps. Once in powerapps, I use the parse JSON feature to add them to a collection. Each row has a 'Global Unique Identifier' field. Below is an example of 4 rows being imported and their ID.

AMD_0-1665737829972.png

Now, once I import them, I want to loop through the records and find any that has a duplicate ID (as seen in the above example, two records have a matching ID). I then want to add the rows containing the duplicates to another Collection to be displayed in a gallery.

I'm using the below code to do this.

 

ForAll(
 importCollection,
 If(
 CountRows(
 Filter(
 importCollection,
 GlobalUniqueID = ThisRecord.GlobalUniqueID
 )
 ) > 1,
 Collect(
 errorCollection,
 {
 errorField: "Global Unqiue Identifier",
 GlobalUniqieID: ThisRecord.GlobalUniqueID,
 errorValue: ThisRecord.GlobalUniqueID,
 errorType: "Unique ID",
 errorMessage: "Duplicate Global Unique Identifiers found."
 }
 )
 )
 );

 

 
My logic is to count the number of rows that have the same ID as the record, and if there is more then one, add them to the error collection.

However, when I run this, all records in the importCollection are returning true for this condition and being added to the error Collection.

AMD_1-1665738490870.png

 

I'm unsure where my code is going wrong and feel like I'm going mad. Could anyone shine some light on how my approach fails and provide an alternative?

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    156,340 Most Valuable Professional on at

    Hi @AMD ,

    Try this structure

    ForAll(
     importCollection As aCol,
     If(
     CountRows(
     Filter(
     importCollection,
     GlobalUniqueID = aCol.GlobalUniqueID
     )
     ) > 1,
     Collect(
     errorCollection,
     {
     errorField: "Global Unqiue Identifier",
     GlobalUniqieID: ThisRecord.GlobalUniqueID,
     errorValue: ThisRecord.GlobalUniqueID,
     errorType: "Unique ID",
     errorMessage: "Duplicate Global Unique Identifiers found."
     }
     )
     )
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    Visit my blog Practical Power Apps

  • AMD99 Profile Picture
    23 on at

    That worked. Thanks a million!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard