(+351) 21 24 10006  ·  info@bconcepts.pt
Carnaxide, Lisbon

How to extract duplicate rows in Excel with Power Automate: step by step

João Barros 31 de July de 2026 4 min read

This tutorial shows how to create a flow in Power Automate that reads an Excel file, identifies duplicate rows based on selected columns, and writes those rows to a new file for review. It's useful for cleaning databases, avoiding repeated entries and automating data audits.

Prerequisites

  • Microsoft account with access to Power Automate
  • Excel file saved in OneDrive for Business or SharePoint (named table)
  • Basic knowledge of Power Automate (create flow, standard actions)

Step 1: Prepare the Excel file

Open Excel and ensure the data is in a Table (Home > Format as Table). Note the Table name (e.g.: Table1) and choose the columns that define duplication (e.g.: Email, Name).

Step 2: Create an automated flow

In Power Automate, create a new automated flow (Instant cloud flow) with a manual trigger (Manually trigger a flow) to test interactively. This makes debugging easier before scheduling or connecting to an automatic trigger.

Step 3: Get rows from the Excel table

Add the action List rows present in a table (Excel Online (Business) connector). Configure the file and the Table. If there are many records, enable pagination in Settings and increase the threshold.

Step 4: Group and identify duplicates

We will use a combination of actions: Compose to create a comparison key and then Filter array to find duplicates. First, add an Apply to each action that iterates over the output of List rows. Inside, create an object with the concatenated key.

// Example expression for key (concatenates Email and Name, adjustable): concat(item()?['Email'],'|',item()?['Nome']) 

Instead of storing in complex variables, we'll create an array with all keys and then use union and length to detect duplicates.

Step 5: Build key array and detect repeats

1) Add an Initialize variable (Array) action named allKeys. 2) Inside the Apply to each, add Append to array variable with the value of the key expression. After the Apply to each, add a Compose to compute the unique keys:

// Compose UniqueKeys union(variables('allKeys'), variables('allKeys')) 

3) To identify which keys have duplicates, iterate UniqueKeys with an Apply to each and use Filter array on allKeys to count occurrences:

// Filter array condition to match the current key item() == items('Apply_to_each_CurrentKey') 

Then use a Compose with length(body('Filter_array')) to get the number of occurrences. If it's >1, the key represents duplicates.

Step 6: Extract the full duplicate rows

Now that you have the duplicate keys, filter the original Excel rows to return only the rows whose key is in the list of duplicatedKeys. Use a Filter array where each element of List rows is transformed into the same key and checked with contains in the duplicatedKeys collection.

// Example condition in Filter array contains(variables('duplicatedKeys'), concat(item()?['Email'],'|',item()?['Nome'])) 

The result of this Filter array will be the list of duplicate rows with all original fields.

Step 7: Save the duplicates to a new Excel file or CSV

For review, write the results to a new file. You can create an Excel file with an empty Table beforehand, or generate a CSV. For CSV, use the Create file action (OneDrive for Business) and build the content by concatenating headers and lines.

// Simple example of building a CSV line inside an Apply to each concat(item()?['Nome'],',',item()?['Email'],',',item()?['Data']) 

For Excel, use the Add a row into a table action inside an Apply to each over the duplicate rows, mapping columns one by one.

Verify the result

Open the output file (CSV or Excel) and confirm it contains only the rows that appear more than once based on the chosen columns. Also check the counters in the flow (Outputs of the Compose actions) to confirm the number of duplicates matches expected. If rows are missing, verify the key expression and check for spaces or case differences (use toLower to normalize).

Conclusion

This flow allows you to identify and extract duplicate rows in Excel with Power Automate, facilitating data cleaning and review. Next steps: automate the trigger (e.g.: when a file is updated), send an email with the duplicates file or extend the logic to fuzzy rules (e.g.: use of similarity). Tip: normalize strings with trim() and toLower() to reduce false negatives.