Question posted 2013 · +6 upvotes
I have large amount of rows, which look like:
| Name | Value |
|--------|-------|
| name 1 | 12 |
| name 1 | 10 |
| name 1 | 1 |
| name 2 | 55 |
| name 3 | 1 |
| name 3 | 8 |
I need to merge all rows into one row based on column “Name” and sum “Value” in relevant rows. Result should be:
| Name | Value |
|--------|-------|
| name 1 | 23 |
| name 2 | 55 |
| name 3 | 9 |
Rows with the same “Name” could be 0-n.
How can I do it in Google Refine or in Excel/Google Spreadsheet?
I am thinking of it, but with no solution.
Thank you a lot!
Accepted answer +15 upvotes
In OpenRefine or Google Refine:
- Sort by Name column (if not already sorted) and make sort permanent
- Blank Down on name column to remove duplicate values
- On Value column, do Edit Cells -> Merge multi-valued cells
- On same column, do Edit Cells -> Transform with a GREL expression of
forEach(value.split(','),v,v.toNumber()).sum() - Facet by Blank on Name column, and select True (ie blank rows)
- Use All -> Edit Rows -> Remove all matching rows to delete the redundant rows
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
— top 25%.