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 / Delete duplicates in a...
Power Automate
Unanswered

Delete duplicates in a SharePoint List

(0) ShareShare
ReportReport
Posted on by

Hello all,

I have got a SharePoint List with about 1400 items. It only should be arround 800 items and I found out that many items have duplicates. I don´t know why and that´s also not the point here.
My idea is to create a Flow which will get each row of the list and goes through all other rows and checks if *every* column is equal. If yes then delete this row.

I found this here in the forum:
Solved: Delete Duplicate in SharePoint List - Power Platform Community (microsoft.com)
But this is not exactly what I need I think.
I created this flow (unfortunately it is german) - only 3 conditions as an example. In reallity there are 8 columns.

 
 

Screenshot 2021-01-18 115100.jpg


I did not run it yet as I am pretty sure that this Flow will delete everything - or am I wrong?
How can I achieve that the flow deletes only duplicates but leaves one entry of each?

Thank you in advance!

Categories:
I have the same question (0)
  • fchopo Profile Picture
    8,003 Moderator on at

    Hello @der_cosmicyes 

    You could do the following:

    1) Get all items.

    2) For each item.

    3) Look for an identical one, using get items and an Odata Filter query expression.

    4) If more than one element is found (check the lenght of the ouput of the previous step) -> there is a duplicate.

    5) Delete the item.

    Have a look at this example:

    filterQuery2.png

     

    Therefore, in your "Get Items 2" action, you should write an OData Filter query with the 8 fields to compare.

     

    Have a look at this sources on how to work with this kind of expressions: 

    Every Power Automate (MS Flow) Filter Query You Ever Wanted To Know As A Functional Consultant – DIY D365

    OData Filter query in SharePoint Get items in Flow (sharepains.com)

    Hope it helps!

    Ferran

  • RK-23070616-0 Profile Picture
    on at

    Thank you Ferran,
    Thank you! This sounds a little complicated to a PowerAutomate Newbie. I haven´t heard of OData Filters but I am willing to dive deeper into it.
    But one question:
    Is there no way to combine "my" solution with the idea to check if more than 1 item is found?
    I think my solution would delete everything but if I can check if more than 1 one was found this could be the solution. What do you think?

  • Verified answer
    fchopo Profile Picture
    8,003 Moderator on at

    Hello @der_cosmicyes 

    In your solution you should another apply to each. I mean, when do the comparison, you are comparing the values of the same item, so it will be always true, and therefore, it will delete all items.

    You need an algorithm like that:

    1) Get ALL items.

    2) For each item.

    3) Get ALL items AGAIN

    4) For each item in step 3, compare it against the item in step 2.

    5) If the values are the same, remove it.

    If you find the use of OData filters too complicated, you could do something like this:

    getitems.png

     

    Hope it helps!

    Ferran

     

  • RK-23070616-0 Profile Picture
    on at

    Thank you Ferran,
    I have not tried yet but this seems very good to me!
    Espacially the condition ID(1) is NOT equal to ID(2) is a very good idea.
    I will try as soon as possible and then Accept as Solution (I hope 😉 )

    Best regards

  • RK-23070616-0 Profile Picture
    on at

    Hi Ferran,
    ok, I know why you wanted me to use OData Query: Performance! 🙂
    Unfortunately I could not solve it using OData.
    I am using now your second approach (which is really very slow...) but it works.
    The only thing I changed ist to use ID of 'Get Items' and not of 'Get Items 2':

    I set up a very small list with Items
    * Paul McCartney
    * John Lennon
    * George Harrison
    * Ringo Starr
    * Paul McCartney

    and used your second approach.
    When deleting ID of 'Get Items 2' both Pauls are gone and the Beatles are a Trio 😉
    Using ID of 'Get Items' worked.
    You helped me very much - thank you!

  • Jltitus Profile Picture
    138 on at

    @fchopo how would you remove all but one? I want to remove duplicates but keep one.

  • Community Power Platform Member Profile Picture
    on at

    Same here! I need to remove all items but one. How can this be achieved?

     

    Thank you!

  • Community Power Platform Member Profile Picture
    on at

    I solved this recently. I have an automation that finds duplicates from a Sharepoint Online List and removes duplicates, leaving the original one.

     

    The start of the flow is the same as the example before, so you use Odata to filter the items and check that the length of the results is more than 1. There are some changes I made after that and one change at the beginning of the flow. I created a variable. The variable contains the Sharepoint List data and the variable is updated after each filtering. At the end of the flow, I extract the List item ID's from the Array and use those ID's in the "Delete item" part. My flow is in finnish, but i'll try to explain with a picture:

    automaatio.png

     

    Hope this helps!

  • benksyong Profile Picture
    6 on at

    Thank you on your sharing.

    Would it be okay for your to share more detail how the ODATA FILTERED ITEMS configured? 

     

    I've tried, but it does not work. I'm new in Power automate, I wish to learn more how it works to improve the performance. 

  • Community Power Platform Member Profile Picture
    on at

    Sure!

     

    Select the "Get items" step, and open the advanced settings. Then type the code in the Odata filtering field. My code is below, but you can use whatever suits your needs. The field names are case sensitive, so keep that in mind.

     

    odatafilter.PNG

     

    Does this answer your question?

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 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard