Reputation: 89
So I am in Google Sheets and need to be able to add up all the values in part of a column, as long as the cell first cell in the same row is consistent. Example:
If you take a look at the image, I have calculated the sum of 'record_count' for all the cells where 'Name' = 'Booker' - it's about 80 rows. I did this by manually defining the range. I need to be able to use a formula that will sum every cell in 'record_count' as long as the 'Name' (column B) is consistent. Once 'Name' changes, I need the formula to start summing up every cell where 'Name' = a different name.
I will be pasting this data from the output of a monthly SQL query, and don't want to have to keep manually defining ranges. I want it to be dynamic. If I got down past row 80 the Name changes to 'Softhouse' and I want to be able sum every cell in 'record_count' where 'Name' = 'Softhouse'.
The formula I currently have in J3 is =IF(C3=C4,SUM(D$3:D$80),null)
This only works for the first use, then gradually decreases if I drag it down.
Any help at all would be most appreciated. Also, I can provide as much extra info as needed.
Upvotes: 3
Views: 502
Reputation: 50416
QUERY
will give you a summary:
=QUERY(A:I,"Select A,sum(D) group by A",2)
The correct implementation of IF
is
=ARRAYFORMULA(SUM(IF(C3=C$3:C$80,D$3:D$80)))
Upvotes: 2
Reputation: 80
You can use the function sumif: https://support.google.com/docs/answer/3238496
For your case,try this function below,just change 99 to big enough for your real data: J3=SUMIFS(D$3:D$99, B$3:B$99, CONCATENATE("=",B3))
Here is a sample:
Upvotes: 1