In this Power Automate article, we will see how to remove duplicate items from SharePoint Online List using Power Automate flow.
Recently, I got a requirement to delete duplicate items from a SharePoint Online list using a flow.
Remove duplicate items from a SharePoint list using Power Automate
Let us see how to delete multiple duplicate items from a SharePoint Online list using power automate flow.
We use Power Automate flow, to delete multiple duplicate items in a SharePoint. Because we can choose the manual approach to delete multiple items, there are chances to delete a unique item without noticing the list item.
So in the following, we will use the below SharePoint list which has a repeated list of items (highlighted in red). By using the Power Automate flow we will remove those duplicate items.
Our entire flow looks like the below:
Here, we will create a flow that trigger manually, follow the below steps:
Step:1
Log into Power Automate, select the instant cloud flow -> select trigger as Manually trigger a flow -> enter the flow name -> click create option.
Step:2
- select the +new step and add the Get items to trigger action from the action triggers.
- Configure the SharePoint site address and list name. In the Filter Query, add the below expression to filter the employee’s active status:
Status eq 'Active'
Step:3
- Now add a +new step and select data operation, to get the filtered values from SharePoint to get items action.
- In the from field, pass the dynamic content of values and add the key-value pair, where the key is the Title key, and for the value pass the dynamic content value as shown below:
Step:4
To remove the duplicate values and keep only the unique list items, we can use the Union function. Add a compose action and pass the below expression as input which finds the duplicate values and stores only the unique values from the list.
union(body('Select'),body('Select'))
Step:5
- Now Add a apply to each action and pass the Output of the compose action.
- Select +New step and add Filter array action. From the field pass the values of the SharePoint list and check the Title is equal to the mentioned expression which has the current item value.
Step:6
- In the same way, add an apply to each action and use the Skip function to remove only the duplicate values.
- The skip expression skips the first item and loops through the rest in another Apply to each action from the filter array outputs.
- Pass the below expression in apply it to each action output value, here we will pass the parameter value as 1 so it skips the first list value.
skip(body('Filter_array'),1)
Step:7
Now add a Delete item action to delete items using their ID. In the ID pass the below-mentioned expression. Click the ok or Update button.
item()?['ID']
Step:8
Save, Test, and run the flow, our flow has run successfully like below:
When we expand the delete item action, we can see based on the ID it deletes the list item in SharePoint List.
- Open and Refresh the SharePoint Online list.
- In the below screenshot, we can see it removes the duplicate values in the SharePoint list using the power automate flow.
This is how to delete multiple duplicate items in a SharePoint Online list using power automate flow.
Conclusion
In this Power Automate article, we saw how to remove duplicate items from a SharePoint Online List using Power Automate or Microsoft flow.
You may like the following Power Automate tutorials:
- Power Automate Multilevel Approvals
- Power Automate Apply to Each Current Item
- Create SharePoint Online List using Power Automate
- How to Parse JSON Object to Array in Power Automate
- Format date to iso 8601 in Power Automate
- How to Merge Word Documents in Power Automate?
After working for more than 15 years in Microsoft technologies like SharePoint, Office 365, and Power Platform (Power Apps, Power Automate, and Power BI), I thought will share my SharePoint expertise knowledge with the world. Our audiences are from the United States, Canada, the United Kingdom, Australia, New Zealand, etc. For my expertise knowledge and SharePoint tutorials, Microsoft has been awarded a Microsoft SharePoint MVP (9 times). I have also worked in companies like HP, TCS, KPIT, etc.
The “Filter Array” action has an error – its result will be all the items collected from the list, since it compares the same values (both are the Title value from “Get items” action).
The expression on the right should be items(‘Apply_to_each’)?[‘Title’]
Hi Bijay,
I followed the steps and it returned a successful result however it didn’t delete the duplicates.