Sum Numbers by Type in an Excel Cell Using Power Query
Question details
Extract and total numbers associated with repeated labels stored together in an Excel cell.

- Product
- Microsoft Excel Power Query
- Device & OS
- not provided
- Scenario
- A cell contains multiple label-and-value pairs, and the user wants a total for each label.
- Observed behavior
- The desired result is a table with one row per label and the sum of its associated numbers.
Check how the pairs and their labels and numbers are separated. The steps below use a cell containing A 10, B 5, A 3, with commas between pairs and spaces between labels and numbers.
Split and group the values with Excel Power Query
Use Power Query to turn the contents into rows and calculate a total for each label.
For the example A 10, B 5, A 3, the result is A = 13 and B = 5. If your data uses different separators, choose those separators in the split steps.
Select the column containing the combined values, then choose Data > From Table/Range. Confirm the table range and header setting.
To calculate separate totals for each original cell, choose Add Column > Index Column before splitting. Keep this index for the grouping step.
Select the combined-values column and choose Split Column > By Delimiter. Select the comma, open Advanced options, choose Split into Rows, and confirm. Then use Transform > Format > Trim on the resulting column.
Select the split column and choose Split Column > By Delimiter. Select a space and split at the left-most delimiter into columns. Rename the columns Type and Value, then set Value to a numeric data type using its column-header data type control.
Choose Home > Group By. Group by Type, name the new column Total, select Sum, and choose Value as the column. For separate totals per original cell, use Advanced grouping to include the index as well as Type. Select Close & Load to return the result to Excel.

Sum Label Values in WPS Spreadsheets
For a small list of comma-separated pairs, use Text to Columns to separate the entries, then use SUMIF to total each label.
- 1. Split the pairs: In a blank worksheet, enter A 10, B 5, A 3 in cell A1. Select A1 and choose Data > Text to Columns, then select a comma as the delimiter.
- 2. Arrange the pairs vertically: Select the resulting cells A1:C1 and copy them. Select A3 and use Paste Special > Transpose to place the pairs in A3:A5.
- 3. Remove extra spaces: Enter =TRIM(A3) in B3 and fill it down through B5. Copy B3:B5 and use Paste Special > Values on the same cells.
- 4. Separate labels from numbers: Select B3:B5 and choose Data > Text to Columns. Select a space as the delimiter to place labels in column B and values in column C. Check that the values in column C are numeric.
- 5. Calculate each total: Enter A and B in E3:E4. In F3, enter =SUMIF($B$3:$B$5,E3,$C$3:$C$5), then fill the formula down to F4.

Frequently Asked Questions
How do I keep totals separate for each original cell?
In Power Query, add an index column before splitting the pairs into rows. In Home > Group By, use Advanced grouping and include both the index and the Type column.
What if my pairs use a different delimiter?
In Power Query's Split Column > By Delimiter dialog, select the character that separates your pairs. Use the appropriate separator again when splitting each label from its value.
Why can't Power Query sum the value column?
The values may be stored as text. Use the data type control in the Value column header to select Whole Number or Decimal Number, and check for nonnumeric characters.
Can I update the totals after changing the source cells?
Yes. After editing the source table, use Data > Refresh All in Excel to rerun the query and update the loaded totals.




