I have a sheet with the following setup

A       B      C
ItemID, Type,  Count
0001,   Apple, 8
0002,   Peach, 3
0003,   Apple, 8
0004,   Pear,  2
0005,   Apple, 4

And I would like to produce the following sheet

D      E
Type,  Total
Apple, 20
Peach, 3
Pear,  2

I can generate the unique Type with UNIQUE and generate the first column of the desired output, but I can't quite figure how to get the second.

I have tried SUMIF(C1:C6, B1:B6==D1:D6) but it seems the == does not do an element-wise matching.

How can I get sub-sums of a column based on another columns unique values?

1 Answer 1


Use query(), like this:

=query(A1:C, "select B, sum(C) where B is not null group by B", 1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.