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 / Duplicate detection in...
Power Apps
Answered

Duplicate detection in collection

(0) ShareShare
ReportReport
Posted on by 1,257 Super User 2024 Season 1

I have a blank gallery to which I dynamically add rows however many I need and then add data to those rows.   On save I create a collection from that data and then I patch it back to a sharepoint list.     All works well.

 

However I now need the functionality to check for duplicates in one of the columns (it's text input, number type) before I patch it through to the sharepoint list. notify the user and give them a chance to update it..  (notify function would be absolutely fine for this)

 

I have read numerous duplicate questions, watch a ton of videos but can't quite get the scenario I need.

 

So somewhere between Collect(mycollection.....  and Patch (mycollection  I need an If duplicate then notify if not then patch !

 

Any ideas gratefully accepted

 

TIA

Categories:
I have the same question (0)
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @vffdd Follow this example and replace mySPCollection with your collection name and Value with the name of your column.

    ClearCollect(mySPCollection, ["1","2","2","3","4","4","5"]);
    If(CountIf(AddColumns(GroupBy(mySPCollection,"Value", "myGroup"), "myCount", CountRows(myGroup)), myCount>1)>0, Notify("Duplicates Found"))

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    brilliant thanks @CNT   I'm almost there.. that worked but showed up another issue I have by making it work 🙂   The next command after the collection has been patched is to navigate to another screen and it's just another command separated by ; from the rest.  However IF there is a duplicate and patch doesn't happen I don't want to navigate?  because I want them to fix it.. I only want to navigate if the patch has taken place.. so how do I join the navigate to the end of the patch as opposed to it being a separate command?  I know if it was a form I could use an on success but don't think there anything similar in patch?   

  • Verified answer
    CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @vffdd Check this out,

    ClearCollect(mySPCollection, ["1","2","2","3","4","4","5"]);
    If(CountIf(AddColumns(GroupBy(mySPCollection,"Value", "myGroup"), "myCount", CountRows(myGroup)), myCount>1)>0, 
    Notify("Duplicates Found"),
    Patch(.......); Navigate(.....))

    In this case Patch and Navigate will be executed ONLY if there are no duplicates!

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    Fantastic, thanks so much amazing what moving a bracket can do !!  🙂

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @vffdd 

    Glad to help!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 392

#2
WarrenBelz Profile Picture

WarrenBelz 364 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 271 Super User 2026 Season 1

Last 30 days Overall leaderboard