根据列和总和值合并多行(Excel,Google优化,Google电子表格) [英] Merge multiple rows based on column and sum values (Excel, Google Refine, Google spreadsheet)
本文介绍了根据列和总和值合并多行(Excel,Google优化,Google电子表格)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有大量的行,如下所示:
名称|价值|
| -------- | ------- |
|名字1 | 12 |
|名字1 | 10 |
|名字1 | 1 |
|名字2 | 55 |
|名字3 | 1 |
|名字3 | 8 |
我需要根据列Name将所有行合并成一行,并将Value相关行。结果应该是:
|名称|价值|
| -------- | ------- |
|名字1 | 23 |
|名字2 | 55 |
|名字3 | 9 |
具有相同名称的行可以是0-n。
我如何在Google优化或Excel / Google电子表格中执行?
我在想,但没有解决方案。 p>
谢谢你!
解决方案
在OpenRefine或Google Refine中: / p>
- 按名称排列(如果尚未排序)并排序永久
- 空白名称列删除重复值
- 在值列上,编辑单元格 - >合并多值单元格
- 在同一列上,编辑单元格 - >转换为$ code> forEach(value.split(','),v,v.toNumber())的GREL表达式sum()
-
使用全部 - >编辑行 - >删除所有匹配的行以删除冗余行
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!
解决方案
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
这篇关于根据列和总和值合并多行(Excel,Google优化,Google电子表格)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文