Search code examples
google-sheetssumgoogle-sheets-formulasumifsgoogle-query-language

Workaround Argument must be a range error when using SUMIF + FILTER


Col A Col B Col C
a back 1
a back 1
b
b draw 1
c back 1
c
d draw 1
d draw 1
e draw 1

In Column E I put the values from Column A using UNIQUE and sorting with SORT:

=SORT(UNIQUE(A:A))

In Column F I tried to put a single formula in the first row, to sum each of the total values in Col C according to some filters:

=ARRAYFORMULA(IF(E1:E="","",SUMIF(
              FILTER(A1:A,(B1:B<>"draw")*(C1:C<>"")),
              E1:E,
              FILTER(C1:C,(B1:B<>"draw")*(C1:C<>""))
)))

But I get the error:

Argument must be a range.

Expected Result:

Col E Col F
a 2
c 1

Is there a way to make the filters become ranges or how should I proceed to avoid this error?


Solution

  • try:

    =QUERY(A1:C, "select A,sum(C) where not B matches 'draw|^$' group by A label sum(C)''")
    

    enter image description here