Search code examples
google-sheetsgoogle-sheets-query

Adding 2 columns together when criteria is met in another column using query


In this sheet¹ ,I need to add 2 columns J & K from the archive tab when column G contains pick.

The formula I have tried is this:

Figures!D7:

=QUERY(Archive!$A:$Y,"SELECT SUM(J)+ SUM(K) where G contains 'Pick'",0)

But I get #value error on it.


Solution

  • QUERY seems to treat the duration values in columns J & K as text

    I would use a FILTER instead:

    =SUM(FILTER(Archive!$J:$K,IFERROR(FIND("Pick",Archive!$G:$G),0)))

    You also need to remove the ,1 from the end of your QUERY in cell A1 of the Archive sheet. It causes row 1 to be treated as a text-format header row.