【发布时间】:2019-09-03 17:56:29
【问题描述】:
我需要能够根据字符串值及其标识符值聚合字符串和另一个单元格的值。
我尝试了几种对值求和并按特定项目过滤的方法,然后尝试根据包含的文本求和,但我没有找到好的方法。
╔══════════════╦═════════════════╗
║ A ║ B ║
╠══════════════╬═════════════════╣
║ Product Name ║ Product Quantity║
╠══════════════╬═════════════════╣
║ ProductA - 1 ║ 12 ║
╠══════════════╬═════════════════╣
║ ProductA - 2 ║ 2 ║
╠══════════════╬═════════════════╣
║ ProductB - 1 ║ 28 ║
╠══════════════╬═════════════════╣
║ ProductB - 2 ║ 21 ║
╠══════════════╬═════════════════╣
║ ProductC - 1 ║ 1 ║
╠══════════════╬═════════════════╣
║ ProductC - 2 ║ 4 ║
╠══════════════╬═════════════════╣
║ ProductD - 1 ║ 98 ║
╠══════════════╬═════════════════╣
║ ProductD - 2 ║ 75 ║
╠══════════════╬═════════════════╣
║ ProductE - 1 ║ 5 ║
╠══════════════╬═════════════════╣
║ ProductE - 2 ║ 9 ║
╚══════════════╩═════════════════╝
我不确定如何处理 sum(A) 和 sum(B),其中 A 包含除标识符之外的相同文本。
目前,我正在执行查询以从较大的数据集中仅获取 A 和 B,然后执行 Find and Replace 以删除所有 - 1 和 - 2,然后执行
=QUERY(A:B,"Select A, sum(B) group by A order by sum(B) desc")```
【问题讨论】:
标签: regex google-sheets array-formulas google-sheets-query google-query-language