简体   繁体   中英

Calculating Sum if Cell in same row is String

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.

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)))

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:

一个sumif样本

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM