Power Query Problems

Transpose Account Rows into One Row per Client in Excel Power Query

Maira MehtabMaira Mehtab Dec 2, 2026 868 views

Question details

Create one row per client with the client address and each account number in a separate column.

Transpose Account Rows into One Row per Client in Excel Power Query
Product
Microsoft Excel Power Query
Device & OS
not provided
Scenario
A source table contains multiple account rows for each client, with client or address values potentially shown only on the first row.
Observed behavior
The desired output is a table with one row per client, a preserved address, and separate columns for the client's account numbers.
Before you start

Check that each client has a stable identifier and one consistent address, and identify blank cells that should inherit values from the preceding row. Confirm that account numbers are stored as text if leading zeros must be preserved.

Solution 1Recommended

Group and pivot account numbers in Excel Power Query

Use this method to turn multiple account rows into separate columns while retaining each client's address.

1
Load the source table

Select a cell in the source data and choose Data > From Table/Range to open it in Power Query Editor. Confirm that the table has headers, including Client ID, Address, and Account Number.

2
Fill repeated client details

Select the Client ID and Address columns, then choose Transform > Fill > Down if blank cells mean the values continue from the row above. Check the results, especially at client boundaries, so an address is not carried into the wrong client.

3
Prepare the columns

Set Account Number to the Text data type, filter out rows without an account number, and remove columns you do not need in the output. Keep Client ID, Address, Account Number, and any other consistent client-identifying columns you want to preserve.

4
Group the client rows

Choose Home > Group By, select Advanced, and group by Client ID, Address, and any other retained client-identifying columns. Name the new column Rows and choose All Rows as the operation.

5
Number accounts within each group

Choose Add Column > Custom Column, name it Indexed Rows, and enter Table.AddIndexColumn([Rows], "Account Index", 1, 1, Int64.Type). Remove the original Rows column, then expand Indexed Rows and select only Account Number and Account Index.

6
Pivot the account numbers

Select Account Index and choose Transform > Format > Add Prefix to add Account as a prefix, or create a text column with "Account " & Text.From([Account Index]). Select the resulting index column, choose Transform > Pivot Column, and select Account Number as the values column. Under Advanced options, choose Don't Aggregate.

7
Load the result

Check that each client has one row and that the account columns contain the expected values. Choose Home > Close & Load to return the table to Excel.

Group and pivot account numbers in Excel Power Query
Check grouping and account order: Different addresses for the same Client ID produce separate groups. If account column order matters, sort the rows within each grouped table by an appropriate source-order field before adding the index.
Free Microsoft Office alternative

Review client account tables with WPS Spreadsheets

WPS Office is a free, lightweight alternative with a familiar spreadsheet interface. Open compatible Excel files to review and edit the resulting client account table as you migrate between Office tools; Excel Power Query itself remains a Microsoft feature.

Review one-row-per-client account tables in a familiar spreadsheet interfaceOpen and edit compatible Microsoft Excel XLSX filesUse a free, lightweight Office alternativeMove between common Office document formats with ease
microsoft office alternative - wps office

Frequently Asked Questions

Why did one client appear on more than one output row?

The grouping uses both Client ID and Address. If a client has different address values, Power Query creates separate groups. Check and standardize the address values before choosing Home > Group By.

How can I keep leading zeros in account numbers?

In Power Query Editor, select Account Number and set its data type to Text before pivoting. If zeros were already removed from the source, restore them from the original data first.

What happens if clients have different numbers of accounts?

The pivot creates enough account columns for the largest group. Clients with fewer accounts have null values in the extra columns.

Can I refresh the result when new accounts are added?

Add the records to the source table, then use Data > Refresh All in Excel. Power Query reruns the transformations and updates the loaded table.

Does WPS Spreadsheets run this Excel Power Query?

The grouping and pivot steps described here use Microsoft Excel Power Query. WPS Spreadsheets can open compatible XLSX files for reviewing the resulting table, but it is not a replacement for running this Power Query workflow.