Combine Multiple Conditions into One Excel Row per Person
Question details
Combine repeated person records so each person has one row with their conditions in separate columns.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet contains multiple records for each person, with a condition on each record.
- Observed behavior
- The desired result is one row per person and date of birth, with associated conditions displayed across columns.
Check that the source data has headers for Person, Date of Birth, and Condition, and that dates are stored consistently. Select the data and choose Insert > Table so Power Query can use it as a named source.
Group and pivot conditions with Excel Power Query
Use Power Query to create a refreshable table with one condition per numbered column.
Select a cell in the source table, then choose Data > From Table/Range.
In Power Query, choose Home > Group By. Use Advanced to group by Person and Date of Birth, and set the operation to All Rows with the new column name Rows.
Choose Add Column > Custom Column. Name it Indexed Rows and enter Table.AddIndexColumn([Rows], "Condition Number", 1, 1, Int64.Type). Remove the original Rows column.
Use the expand button on Indexed Rows and select Condition and Condition Number. Change Condition Number to Text, select that column, and choose Transform > Pivot Column. Set Values Column to Condition and, under Advanced options, select Don't Aggregate.
Choose Home > Close & Load. Rename the numbered columns if desired, and use Data > Refresh All after the source records change.

Return conditions across a row with Excel formulas
Use a dynamic array formula when you already have a list of people and want their distinct conditions to spill across columns.
Combine conditions across rows in WPS Spreadsheets
Use a helper column and lookup formulas in WPS Spreadsheets to place each person's conditions in separate columns.
- 1. Set up the source data: Open the workbook in WPS Spreadsheets. Put Person, Date of Birth, and Condition in columns A, B, and C, with data starting in row 2.
- 2. Create a lookup key: In D2, enter =LEN(A2)&":"&A2&"|"&IF(ISNUMBER(B2),TEXT(B2,"yyyy-mm-dd"),B2)&"|"&COUNTIFS($A$2:A2,A2,$B$2:B2,B2). Fill the formula down alongside the source records.
- 3. List each person once: Copy columns A and B to columns G and H, then select the copied data and choose Data > Remove Duplicates. Select both columns so each person and date-of-birth combination appears once.
- 4. Look up conditions across the row: In I2, enter =IFERROR(INDEX($C$2:$C$1000,MATCH(LEN($G2)&":"&$G2&"|"&IF(ISNUMBER($H2),TEXT($H2,"yyyy-mm-dd"),$H2)&"|"&COLUMN(A1),$D$2:$D$1000,0)),""). Fill the formula right for the required number of condition columns, then down for all people. Extend the row 1000 ranges if the source data is longer.

Frequently Asked Questions
How do I update the Power Query result when records change?
Add or edit records in the source table, then choose Data > Refresh All to update the loaded query.
How can I prevent two people with the same name from being combined?
Include Date of Birth in the Power Query Group By fields or in the formula criteria. If that combination is not unique, use a reliable person ID instead.
Why does the Excel formula show a spill error?
Clear any cells to the right of the formula that block its results. TRANSPOSE returns the matching conditions across multiple columns.
Can I keep repeated conditions in the output?
Yes. The Power Query numbering method keeps each source record. In the Excel formula method, remove UNIQUE from the formula to retain repeated values.




