Reputation: 32124
:) I'm trying to learn google sheets and there is something that I want to do and I can't figure out how.
A B
5 yes
3 no
yes
2 yes
yes
5 no
no
3 no
yes
yes
3 yes
no
no
5 no
=SUM(A1:A14)
as you can see in this example i have two columns
A
- a number
B
- yes or no
at the bottom I added =SUM(A1:A14)
and it sums column A properly.
what If i want to sum column A only on rows that has yes
in column B?
how can I do that ?
thanks!
Upvotes: 1
Views: 2500
Reputation: 1
try:
=SUM(QUERY(A:B; "select A where B='yes'"; 0))
or:
=SUM(FILTER(A:A; B:B="yes"))
or:
=INDEX(SUM(IF(B:B="yes"; A:A; )))
Upvotes: 1
Reputation: 1574
=SUMIF(B:B,"yes",A:A)
And if you expand into more columns, than =SUMIFS()
will allow multiple conditions.
Upvotes: 2