I have 3 columns and what I need to do is a query where I can see Lab name, Sum Job count only N, Sum redos only Y. I tried with array, but not let me get the conditional Col2=N, Please help me.

=query({A2:B,ArrayFormula(if(C2:C="y", B2:B,0))}, "select Col1, sum(Col2), sum(Col3) where Col1 <> and Col2 ='N', '' group by Col1 label sum(Col2)'', sum(Col3)''", 0)

enter image description here

  • If using a pivot table is an option, it would be much easier done than by using queries and array formulas.
    – Oren
    Commented Apr 6, 2022 at 19:34

1 Answer 1


You haven't shown where your posted sample resides in the spreadsheet, so I'll assume that the header "Lab Name" is in A1 with the rest taking up the top of range A:C. Given this, the following formula should work:

=ArrayFormula(QUERY({A2:A,B2:B*(C2:C="N"),B2:B*(C2:C="Y")},"Select Col1, SUM(Col2), SUM(Col3) WHERE Col1 Is Not Null GROUP BY Col1 LABEL SUM(Col2) '', SUM(Col3) ''"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.