Georodin
Georodin

Reputation: 341

SUM a column by IF criteria in second column - Google Sheets

I have a table like this with two columns (A and B) - the first column contains times, the second column contains "checkboxes":

12:00:00 x  
10:00:00 
13:00:00 x

I want to SUM up all times with an "x" so the outcome should be 25:00:00.

I tried with =VLOOKUP(A4;A1:B3;1;FALSE) the key is A4=x sadly this does not work! (x was not found)

Upvotes: 0

Views: 127

Answers (4)

player0
player0

Reputation: 1

=TEXT(SUMIF(B:B, "=x", A:A), "[h]:mm:ss")

0


=TEXT(SUM(FILTER(A:A, B:B="x")), "[h]:mm:ss")

0


=ARRAYFORMULA(TEXT(SUM(IF(B:B="x", A:A, )), "[h]:mm:ss"))

enter image description here


=TEXT(SUM(QUERY(A:B, "select A where B ='x'")), "[h]:mm:ss")

0


=TEXT(SUMPRODUCT((B:B="x")*(A:A)), "[h]:mm:ss")

0

Upvotes: 1

Gary's Student
Gary's Student

Reputation: 96753

Something like:

=SUMPRODUCT((A1:A100)*(B1:B100="x"))

enter image description here

with the proper formatting applied.

Upvotes: 0

Error 1004
Error 1004

Reputation: 8220

You could use:

=SUMPRODUCT(($B$1:$B$3="X")*($A$1:$A$3))

Upvotes: 0

GalAbra
GalAbra

Reputation: 5148

SUMIF is what you're looking for:

=SUMIF(B:B, "=x", A:A)

Where B:B is the range to match to the condition =x and A:A is the range to sum when the condition is met.

Upvotes: 1

Related Questions