Search code examples
google-sheetsaveragegoogle-sheets-formulasumifs

How to use the SUMIFS function in an ARRAYFORMULA, matching two criteria, to avoid copying down?


Update: This is a duplicate question - see : Google Sheets ArrayFormula with Sumifs

I am raising this question because someone asked it today in a poorly structured question, and theirs was blocked for answering. A similar question was answered previously on SO, but it did not involve separate criteria columns. I'm just trying to offer an answer that I came across while researching the question.

The question was how to do an SUMIFS, (and an AVERAGEIFS) comparing a range to two other columns, without having to do a dragdown of an SUMIFS type formula. Here is what the data looks like, in columns A:C. The criteria to match are in columns F and G. enter image description here


Solution

  • why not:

    =QUERY(A2:C, 
     "select A,B,sum(C),avg(C) 
      where A is not null
      group by A,B
      order by B
      label sum(C)'',avg(C)''")
    

    enter image description here