ellierad
ellierad

Reputation: 27

How to SUM a column of values in Sheet A IF a different column of values IS EQUAL TO a column of values in Sheet B

I am working with Google Sheets/Excel. In Sheet A, I have the names of customers who have purchased various items, along with the cost of those items.

Sheet A

Column A Column B Column C
Customer A Toothbrush $1.00
Customer B Pencil $2.00
Customer C Tent $5.00
Customer C Juice $4.00

In Sheet B, I want to calculate the total amount of money spent by each customer, by referencing their name from Sheet A.

Sheet B

Column A Column B
Customer A $1.00
Customer B $2.00
Customer C $9.00

This is what I have tried so far. I put these formulas into Sheet B, Column B:

=COUNTIF(A:A,"='Sheet A'!A:A")

=SUMPRODUCT('Sheet A'!C:C,COUNTIF(A:A,"='Sheet A'!A:A))"))

Upvotes: 1

Views: 64

Answers (1)

Harun24hr
Harun24hr

Reputation: 36780

In google-sheet you can use QUERY() function like

=QUERY(A1:C4,"Select A, Sum(C) Group By A Label A 'Customer', Sum(C) 'Sum'")

If you want result in Sheet2 then use below

=QUERY(Sheet1!A1:C4,"Select A, Sum(C) Group By A Label A 'Customer', Sum(C) 'Sum'")

enter image description here

In Excel-365 I use below formulas

E2=UNIQUE(A1:A4)
F2=SUMIFS($C$1:$C$4,$A$1:$A$4,E2#)

enter image description here

Upvotes: 2

Related Questions