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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Remove Duplicates from...
Power Automate
Answered

Remove Duplicates from a Sharepoint List

(0) ShareShare
ReportReport
Posted on by 37

I have an issue where duplicates are getting made in a Sharepoint List and I would like Flow to on a schedule get all the items in a list and then for each duplicate   The Key to finding the duplicates would be Employee ID so Find items with the same EEID.

then for every duplicate, it finds send me an email

I am open to using REST if someone can help me with how to accomplish this.

Thanks

 

 

Categories:
I have the same question (0)
  • Jay-Encodian Profile Picture
    2,920 on at

    Hey @jeckard 

    I'd suggest setting the column to enforce unique values to prevent the addition of duplicates:

    1.png

    HTH

    Jay

  • jeckard Profile Picture
    37 on at

    Hey, Jay, I think you meant to upload an image but nothing came through??

  • Jay-Encodian Profile Picture
    2,920 on at

    Hey @jeckard, sorry try now?

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    If you just want to scan for duplicates and send an email for each duplicate then you can just do two Apply to Each loops, with one inside the other.  Before the first loop do a get items and inside the first loop do a get items again.  Then in the second loop compare the value of the record from the first loop with the record from the second.  If its a match then send an email.  I used a list that has a Project choice field, just substitute the Employeeid field.

    screenshot.png

  • jeckard Profile Picture
    37 on at

    I will give you solution a try tonight and let you know!

  • jkeckard007 Profile Picture
    108 on at

     

     I tried the solution you suggested I believe I might be setting up the loops incorrectly

    Can you clarify Value one and Value two as I am getting the system creating a  apply to each loop three?

     

    Loop2.png

  • v-alzhan-msft Profile Picture
    on at

    Hi @jeckard ,

     

    Please refer to screenshot below to create the flow:

    1.png

     

    Best regards,

    Alice       

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Jay-Encodian Profile Picture
    2,920 on at

    @jkeckard007 

    I think you'll need @Pstork1 to provide some more guidance here... but I think you'll need to do the following:

    1. Delete the 'Apply to each 2' and 'Apply to each 3' (and contained actions)

    2. Re-add a 'Condition' action directly underneath the second 'Get Items' action

    3. Select the 'Employee ID' value from the 'Get Items 1 and compare to the the 'Employee ID' value from the 'Get Items' 2... that should set the loop up correctly.

    This will find duplicates but its a pretty expensive query, and it won't work for large lists (above 5000) even after enabling pagination... Working with @Pstork1 excellent suggestion I updated to the following but it still suffers the same limitation with the original query... the second query is slightly quicker as it will return a smaller result set and only do something if the array is greater than 1... i..e a duplicate exists.

    1.png

      This is still not really correct and needs more logic to be added a single duplicate would result in 2 separate emails (One for each duplicate item)... if your list contains less than 5000 items this may work, but I'd really suggest disabling duplicates on the list as per my original suggestion.

    If you're list is above 5000 items I think will need a direct REST query using a CAML query to perform a GroupBy type query (I know distinct isn't support by ODATA)...

    HTH

    Jay

     

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    If you compare your screenshot to mine you will see that I have two get items statements and two loops.  You have one get items statement and three loops.  From what I can see I assume your first get items isn't shown in the screenshot.  If so, then I don't see a need for Apply to each 2.  Remove that loop.  The outside loop should be the first Get items value and the inside loop should be the second.

  • Verified answer
    jeckard Profile Picture
    37 on at

    Here is what I ended up doing and it works.  It would be nice to get all the ID in an array and then delete them all but the first one...That will be the next thing.

    Duplicate1.PNGDuplicate2.PNGDuplicate3.PNG

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard