0

Input:

I have the following data;

C D
1 $1 ABC
2 $2 ABC
3 $3 DEF
4 $4 ABC

I want to create another table in the same sheet where I want to add the values in Column C based on the keys in Column D.

Output:

G H
1 ABC $7
2 DEF $3

Here $7 is the sum of values corresponding to ABC and $3 is the sum of values corresponding to DEF.

So I need something like "= Sum of values in Column C corresponding to Key in G1 found in Column D" in H1 and so on...

What's the best way to achieve this instead of adding the values manually?

Thank you for your help.

2
  • " I want to add the values in Column A based on the keys in Column B", where are those two colums? You have only shown C and D. Commented Jan 26, 2023 at 4:35
  • Sorry, edited it now. But, I also found the solution which I posted as an answer. Thank you.
    – user285645
    Commented Jan 26, 2023 at 4:37

2 Answers 2

0

I solved it using SUMIF.

The formula for H1 would be:

=SUMIF(D:D,G1,C:C)

Alternatively, you can also use Pivot table to group and sum the values of column C based on column D.

0

Your sample data:

Sample Data

In cell C10, use this formula:

=SUMPRODUCT(($C$2:$C$5=B10)*$B$2:$B$5). Drag down to fill other cells in the column:

Final

You'll get the sum of all matched values.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .