首页 > 解决方案 > 在 Excel 中组合附加到同一变量的多个值

问题描述

我需要将与同一变量相关的多个值添加到一个条目中。这是我的工作表的样子:

    ColA   ColB   ColC
    Onion  Ounces  12
    Onion  Ounces  6
    Carrot Kilo    3
    Basil  Grams   25
    Carrot Kilo    6
    Basil  Cups    3

这是我想弄清楚的方法:

    ColA   ColB   ColC
    Onion  Ounces  12
    Onion  Ounces  6
    Carrot Kilo    3
    Basil  Grams   25
    Carrot Kilo    6
    Basil  Cups    3
    __________________
    Onion  Ounces  18
    Carrot Kilo    9
    Basil  Grams   25
    Basil  Cups    3

*如果 colA 匹配(两个条目都是 'Basil'),但 colB 不匹配(一个条目是 'ounces',一个是 'cups'),它需要有单独的条目。

我对excel很陌生,甚至不知道如何正确地表达这个问题,所以如果这个问题已经被回答过很多次,我深表歉意!

非常感谢你的帮助!

标签: excelgoogle-sheetsspreadsheet

解决方案


使用查询

=QUERY(A1:C6,"Select A,B,Sum(C) group by A,B")

在此处输入图像描述


推荐阅读