Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Template
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

How to delete duplicate items in a SharePoint list with Power Automate

Posted on January 9, 2022January 9, 2022 by Tom

“The SharePoint list is a mess, there’re so many duplicate items that it would take hours to delete them, can I build a Power Automate flow to do it for me?”


Power Automate flow doesn’t have to be always a repeatable flow, started on regular basis or on specific event. It can be a flow that you’ll start manually only once or twice, just to do a specific task. Some task that has clear rules, but is very time consuming. For example, deletion of duplicate items from a SharePoint list.

You could do it manually – create a view, sort the items, and go through all of them and delete duplicates. But the manual approach has a few downsides: it can take some time, and it’s easy to make a mistake. You can miss one duplicate, or delete a unique item without even noticing. That’s when it makes sense to delegate the work to a flow – to do it fast and without any mistakes.

Get all the items

If you want to search for duplicates and delete them, you must find them first. Get all the items using the ‘Get items’ action on the list. This is also the place where you define which of the duplicates you want to keep. Is it the first item, or the last item? Use the Order By field to keep the desired items at the top, e.g. to keep the latest items:

Modified desc

Find the duplicate items

Since you want to keep only the unique items, there must be a column that should stay unique. ‘Select’ only this column, e.g. the Title, and in a following ‘Compose’ keep only the unique values. It’s the same approach as used to send only one email per user.

union(body('Select'),body('Select'))
Power Automate delete duplicate SharePoint

The result of ‘Compose’ will be only the unique values. Go through the values one by one inside ‘Apply to each’, and for each of them find the duplicates using ‘Filter array’.

Power Automate delete duplicate SharePoint

You’re searching for all the items where the column that should be unique contains the currently processed unique value.

Remove only the duplicates

Here comes the tricky part. The ‘Filter array’ gives you all the items with the specific unique value, now you want to delete all of them except one – the one that should stay. And since you sorted the items already in the ‘Get items’, it’s the first item it’ll find.

Use the skip(…) expression to skip the first item and loop through the rest in another ‘Apply to each’.

skip(body('Filter_array'),1)

Then just delete all the remaining items using their ID.

item()?['ID']
Power Automate delete duplicate SharePoint

At the end of the flow you’ll have only the unique items in the list.

Summary

This article described a flow to delete duplicate SharePoint items using Power Automate, but there’s one more idea behind this post: flows are not limited to repeated tasks, even though that’s the main use case. You can build a simple flow also for one-time tasks, like removing duplicates or copying files, the flow doesn’t care.

If the task has clearly defined steps that you’d have to do over and over and over again, you might consider building a flow. But always consider the amount of work! You shouldn’t spend 1 hour building a flow to do a 30 minutes manual task.


🚀 Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

31 thoughts on “How to delete duplicate items in a SharePoint list with Power Automate”

  1. Leandro says:
    January 10, 2022 at 2:25 pm

    Great flow, Tom, thanks for sharing!

    Reply
  2. Matt Bishop says:
    January 13, 2022 at 4:48 pm

    Hi
    This was exactly what I was looking for, however, I can’t seem to get the filter to output anything. The only difference in my flow is that my Select box has a key/value entry, so I’ve put ‘Title’ as text for the key and the column ‘Title’ in the value.
    Can you help?
    Thanks

    Reply
    1. Tom says:
      January 16, 2022 at 10:50 am

      Hello Matt,
      use the button on the right side of the ‘Select’ action to hide the ‘Key’ column and keep only the one for the value, as used in the post.

      Reply
      1. DT says:
        March 16, 2023 at 2:27 pm

        We receive work from List A to List B
        I work on List B. I created a Choice column called status- and I added choices of New item, Duplicate item, completed, and Under review.

        Sometimes we receive duplicate items in List B from List A, I would like to identify those duplicates every time when a new item is created in List B and I want to change the status to Duplicate item if the manufacturer’s part number is matching.

        I used your workflow “Delete Duplicate Items” and made minor modifications. Instead, Delete item I added Update Item to change the status value and change the status value to “Duplicate Item”

        The problem I am having all the new items added to my list now the status value has changed to Duplicate Item even though it’s not a duplicate Part#

        Reply
        1. Tom says:
          March 29, 2023 at 8:06 pm

          Hello DT,
          I can’t give advice in comments if you modify the flow as I don’t know what your flow looks like. If you’d like to take a look on the flow together you can book a consulting session.

          Reply
      2. Mack says:
        May 12, 2023 at 10:34 pm

        Hi Tom!

        Could you share a screenshot of this step, please? I’m having the same issue and I can’t find where to hide the ‘key’ column as you mentioned. Thank you!

        Reply
        1. Tom says:
          May 28, 2023 at 3:13 pm

          Hello Mack,
          in the ‘Select’ action click on the small icon highlighted in this article: https://tomriha.com/how-to-select-specific-values-from-an-array-in-power-automate/

          Reply
  3. Dom says:
    July 14, 2022 at 11:34 pm

    Hiya, this is great thanks! Would it be possible to have this as an automated flow?

    Reply
    1. Tom says:
      July 26, 2022 at 9:51 pm

      Hello Dom,
      sure, just use Recurrence trigger instead of a manual one.

      Reply
  4. Louise says:
    July 21, 2022 at 10:24 am

    hi
    could you advise if I want to remove the duplicate item which with more than 2 conditions.
    For example, employee# and date, only remove when employee# and date are duplicated, and keep the last post one.

    item1 employee#2 date 7/21,
    item2 employee#2 date 7/21,
    item3 employee#2 date 7/20
    ==>remove item1

    Reply
    1. Tom says:
      July 26, 2022 at 10:04 pm

      Hello Louise,
      just use multiple filters in the ‘Filter array’ action: https://tomriha.com/how-to-apply-multiple-conditions-in-the-filter-array-power-automate-action/

      Reply
  5. Aris says:
    August 26, 2022 at 11:44 am

    Hello,

    I would to ask, in skip example.. i would like to keep the last iteam added and delete the oldest

    Reply
    1. Tom says:
      September 4, 2022 at 7:34 pm

      Hello Aris,
      that’s what the example does, keeps the newest item.

      Reply
  6. Arie K says:
    August 31, 2022 at 10:54 am

    Hi Tom, this is great!!
    I just need to keep the oldest item and delete the newer ones.
    how can i edit the expression to do it?

    Reply
    1. Rob H says:
      September 4, 2022 at 3:47 am

      In the get items Order By field, add Created Desc so this will list the items on newest to oldest then when the delete skips the first file it is skipping the newest one.

      Reply
    2. Tom says:
      September 4, 2022 at 7:48 pm

      Hello Arie,
      it always keeps the first item returned by the ‘Get items’, and the item at the top is selected by the ‘Order By’ field. If you sort the items in desc (descending order) it’ll keep the newest one, if you sort them in asc (ascending order) it’ll keep the oldest one.
      Just replace the value in ‘Order By’ field with Created Desc as Rob wrote.

      Reply
  7. Rob H says:
    September 4, 2022 at 3:50 am

    Great post, really useful. I managed to modify it and add it to my weekly flow that uploads new items to check just the new entries for duplicates in the existing list and remove all but the most recent.

    Reply
  8. pkd says:
    September 27, 2022 at 7:38 pm

    The delete option at the bottom gets greyed out. Even though I have results from the previous filter. Any idea what could be causing this?

    Reply
    1. Tom says:
      October 5, 2022 at 2:35 pm

      Hello pkd,
      if it’s grey then there’s nothing to delete, the action was skipped. I’d double check the dynamic content used in the loop.

      Reply
  9. Paul S says:
    October 1, 2022 at 2:44 pm

    Hi Guys, found this and looked perfect for what I wanted but all looks ok (i’ve a novice however) and flow runs but nothing is deleted from the sharepoint list.

    Basically I have a Microsoft Form which with a power automate, copies the content from the form on submit to a sharepoint list (works a treat); I even have one that runs at 00:00 and clears the sharepoint list for the next days input (again works a treat). However, based on user input in to the form (and it is expected behaviour) that a user could input more than once into the form which gives two (or more) entries in the form / sharepoint list. I only want to keep the most recent entry from the user. The user would input a “pin code” (just a number) to identify their entry. So in the sharepoint list i could have the pins stored (with other data elements of course) of 9000, 9000, 2000, 2000, 3000 (the order being based on newest being ordered first (so the second record of the 9000 is the first entry and the first 9000 is the most recent).

    All looks good as far as this flow went and in my mind it would do the job. When I test and run the flow it is green and working but the duplicates in the sharepoint list aren’t deleted.

    In the get items section i’m sorting on Modified desc
    In the select its Value and I chose the sharepoint field of ParentPin (is that right?)
    Compose is doing the union formula
    Apply to Each is the compose output
    Filter array is Value and ParentPin
    Apply to Each 2 is the Skip
    Apply to each 3 is the Value
    Delete is SharepointID

    Test works but no data deleted from the sharepoint list
    When I look at the run test history it does appear (from my novice head) that it is taking all the values to start 9000, 9000, 2000, 2000, 3000 and the compose is showing only 9000, 2000,3000 which would be corrected based on the modified date.

    Hoping your Obi-wans can save me from Darth Vader 😉

    thank you in advance.

    Reply
    1. Tom says:
      October 14, 2022 at 10:01 am

      Hello Paul,
      if you’ve got ‘Apply to each 3’ then it’s a different flow, the flow in the article has only 2 ‘Apply to each’ actions.

      Reply
  10. Sandman says:
    November 1, 2022 at 6:40 am

    Im having an issue on the multi column filter (https://tomriha.com/how-to-apply-multiple-conditions-in-the-filter-array-power-automate-action/) can you create another tutorial which mapped exactly on the above steps just add two columns to filter. Thank you in advance.

    Reply
    1. Tom says:
      November 13, 2022 at 6:18 pm

      Hello Sandman,
      I’ll add it to topic ideas list. I’d probably use the concat() expression to connect the two columns together to get the unique values and work with them as a “couple” in the whole flow.

      Reply
  11. Raul Cabezas says:
    December 29, 2022 at 5:59 pm

    Excellent!! It really helped me!!! I wanted this long time ago and in the end i got it! Thanks!!!!!

    Reply
  12. DT says:
    March 15, 2023 at 9:44 pm

    Hello, I need help,

    Subject: Duplicate item in List B
    We receive work from List A to List B
    I work on List B. I created a Choice column called status- and I added choices of New item, Duplicate item, completed, and Under review.

    Sometimes we receive duplicate items in List B from List A, I would like to identify those duplicates every time when a new item is created in List B and I want to change the status to Duplicate item if the manufacturer’s part number is matching.

    Can you some help?

    Reply
    1. DT says:
      March 15, 2023 at 10:02 pm

      I used your workflow “Delete Duplicate Items” and made minor modifications. Instead, Delete item I added Update Item to change the status value and change the status value to “Duplicate Item”

      The problem I am having all the new items added to my list now the status value has changed to Duplicate Item even though it’s not a duplicate Part#

      Reply
  13. Dhaval says:
    March 21, 2023 at 9:49 pm

    Hi Used the same workflow and replaced Delete with Update Status value to reflect as a Duplicate item.
    I appreciate it if you can help me to build a workflow for this SharePoint list. I tried multiple methods but for some reason, it’s updating the status for all new items even though it’s not duplicate.
    1. When the item is created
    2. Search Testid duplicate
    3. if a duplicate testid is found then update the most current date time item Status value to “Duplicate item”
    4. Send an email to Manager- duplicate item found in the list take appropriate action.

    Reply
  14. Garima says:
    March 27, 2023 at 1:49 pm

    My Filter Array output in Apply to Each is coming as an empty array. I am using this @equals(item()?[‘field_4’], item())

    Could you please help

    Reply
    1. Tom says:
      April 9, 2023 at 1:07 pm

      Hello Garima,
      it must be the same column that you use to get the unique values, the one used in the ‘Select’ action. And make sure that you have the ‘Select’ action switched to the text mode only.

      Reply
  15. Tyler K. says:
    June 9, 2023 at 12:36 am

    Much cleaner, flexible, & more efficient way to do this here…
    https://powerusers.microsoft.com/t5/Power-Automate-Cookbook/Find-and-Remove-Duplicates/m-p/2191403#M1611

    Reply
  16. Michelle says:
    July 26, 2023 at 7:18 am

    Awesome, thank you so much

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

🚀 Master Power Automate

Join 2,000+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Still exchanging emails to get things approved?

Use the Approval Process Template and the Task Delegation App to skip the hard part and deploy an automated, fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundle—everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes