Merge Rows in Excel in Power Automate
PDF4me Merge Rows is a Power Automate action that groups duplicate Excel rows by one or more key columns and combines the remaining values into a single consolidated row. Use it to collapse repeated customer, category, or transaction entries into one row per key, or leave the key columns blank to remove exact duplicate rows outright.
What this action does
PDF4me Merge Rows reads an Excel file plus a set of key column numbers, groups rows that share the same key values, and joins the non-key values from each group with a semicolon separator after removing duplicate values within that group. Rows that share every column value are treated as exact duplicates when no key columns are specified.
Authenticating Your API Request
To access the PDF4me Web API through Power Automate, every request must include a valid API key. Authentication validates your identity and enables the connector to reach PDF4me's Excel row merging service from your flow.
Important Facts You Should Not Miss

Map File Content and File Name from a prior action, set Worksheet Numbers and Merge Key Columns, then choose Output Format.
Parameters
Required: File Content, File Name, and Worksheet Numbers must always be provided. Merge Key Columns and Output Format are conditional, each with a defined fallback behavior when left blank.
| Parameter | Required | What it does | Example |
|---|---|---|---|
| File Content | Required | Base64 or buffer content of the source Excel file, typically mapped from a prior action like SharePoint Get File Content or OneDrive. | [File Content from Get File] |
| File Name | Required | Name of the Excel file including its extension, used for processing and naming the output. | test.xlsx |
| Worksheet Numbers | Required | Comma-separated list of 1-based worksheet numbers to process, for example "1,3" targets the first and third worksheets. | 1 |
| Merge Key Columns | Conditional | Comma-separated 1-based column numbers used to group duplicate rows. Leave blank to treat all columns as keys, which removes exact duplicate rows without merging any values. | 6 |
| Output Format | Conditional | Output file format: XLSX, XLS, XLSB, or CSV, matched case-insensitively. Defaults to XLSX when left blank. | XLSX |
What Does Merge Rows Return?
| Field | Type | What it contains |
|---|---|---|
document | Base64 | The Excel document with duplicate rows merged, in the requested Output Format. |
FileName | String | Output filename, for example "merged_rows.xlsx", with the extension matching Output Format. |
Success | Boolean | true when the merge completed, false if the request failed validation or processing. |
Error Message | String | Description of what went wrong, null when Success is true. |
Errors | Array | Detailed error entries with Code and Message, empty when Success is true. |
Common Error Messages
| Error Message | Cause | Solution |
|---|---|---|
Request is empty | Request object is null. | Provide a valid request object. |
Document is empty | Document object is null. | Provide a valid Excel document. |
Invalid worksheet selection | Worksheet number is out of range or in an invalid format. | Use valid 1-based worksheet numbers within the workbook. |
Available worksheets in workbook ({X} total) | Informational detail returned alongside a worksheet validation failure. | Use worksheet numbers from 1 to the reported total. |
Worksheet {number} not found | Worksheet number exceeds the workbook's total worksheet count. | Use a valid worksheet number from 1 to the total count. |
Error processing file: {message} | Generic processing error during the merge operation. | Check file integrity, data structure, and parameter values. |
How Do I Set Up Merge Rows in Power Automate?
- Add PDF4me → Merge Rows to your Power Automate flow.
- Map File Content and File Name from a previous action, such as SharePoint or OneDrive Get File Content.
- Enter Worksheet Numbers as a comma-separated list of 1-based worksheet indexes, for example
1or1,3. - Enter Merge Key Columns as 1-based column numbers to group on, for example
6, or leave blank to only remove exact duplicate rows. - Set Output Format to XLSX, XLS, XLSB, or CSV, or leave blank for the XLSX default.
- Run the flow. Duplicate rows are grouped and merged, and the consolidated file returns as
document.
When Should I Leave Merge Key Columns Blank?
Leave Merge Key Columns blank when the goal is only to remove rows that are completely identical across every column, such as cleaning up an import that picked up the same record twice. Because every column is treated as part of the key in this mode, no non-key columns remain to merge, so the action behaves as a straightforward exact-duplicate remover rather than a value consolidator.
Typical Setups
Workflow ExamplesCommon Power Automate flow patterns using Merge Rows.
- A recurrence trigger runs after a daily order export completes.
- Get File Content retrieves the day's orders workbook from SharePoint.
- Merge Rows runs with Merge Key Columns set to the CustomerID column and Worksheet Numbers set to "1".
- The consolidated file, with one row per customer and order details merged, is emailed to the sales team.
- A flow starts when a new file lands in a "Cleanup" SharePoint folder.
- Get File Content retrieves the uploaded Excel file that may contain repeated rows.
- Merge Rows runs with Merge Key Columns left blank, so only rows identical across every column are collapsed.
- The cleaned file is saved back to a "Cleaned Data" folder.
- A weekly recurrence trigger kicks off inventory reporting.
- Get File Content retrieves the detailed inventory workbook from the system of record.
- Merge Rows runs with Merge Key Columns set to the Category and Subcategory column numbers.
- Product IDs and quantities from matching rows are merged into a single row per category, then archived to the weekly summaries library.
Practical Tips
Cheat Sheet
| Field | Value |
|---|---|
| Action | Merge Rows |
| File Content | Mapped from a prior file-retrieval action |
| File Name | e.g. test.xlsx |
| Worksheet Numbers | 1-based, comma-separated: "1" or "1,3,5" |
| Merge Key Columns | 1-based column numbers to group on, e.g. "6"; blank = exact duplicates only |
| Value merge separator | "; " between deduplicated non-key values |
| Output Format | XLSX (default), XLS, XLSB, or CSV |
| Output | document (Base64), FileName, Success, Error Message, Errors |
Frequently Asked Questions
Industry Use Cases & Applications
- Sales & E-Commerce
- Finance & Accounting
- Human Resources
- Operations & Supply Chain
- Customer Service & Support
- Healthcare & Medical
Sales & E-Commerce Use Cases
- Customer Order Consolidation: Merge multiple orders per customer into single rows
- Product Sales Aggregation: Consolidate sales by product across multiple transactions
- Territory Rollup: Merge sales data by territory or region
- Duplicate Lead Removal: Remove exact duplicate leads from marketing lists
Finance & Accounting Use Cases
- Transaction Consolidation: Merge transactions by account or vendor
- GL Entry Aggregation: Consolidate general ledger entries by account code
- Expense Rollup: Merge expense entries by employee or department
- Duplicate Invoice Removal: Remove exact duplicate invoice entries
Human Resources Use Cases
- Timesheet Consolidation: Merge timesheet entries by employee and pay period
- Training Records Aggregation: Consolidate training completions by employee
- Benefits Enrollment: Merge enrollment selections by employee ID
- Duplicate Employee Cleanup: Remove duplicate employee records
Operations & Supply Chain Use Cases
- Inventory Consolidation: Merge inventory records by location and product
- Supplier Order Aggregation: Consolidate purchase orders by supplier
- Shipment Tracking: Merge shipment entries by tracking number
- Quality Control Rollup: Aggregate QC results by batch or lot number
Customer Service & Support Use Cases
- Ticket Consolidation: Merge support tickets by customer and issue category
- Feedback Aggregation: Consolidate customer feedback by product
- Contact Deduplication: Remove duplicate contact entries
- Interaction History: Merge customer interactions by customer ID
Healthcare & Medical Use Cases
- Patient Visit Consolidation: Merge patient visits by patient ID and date
- Lab Result Aggregation: Consolidate lab results by patient and test type
- Appointment Rollup: Merge appointments by patient and provider
- Prescription History: Consolidate prescriptions by patient ID