Search code examples
google-sheetsarray-formulasgoogle-sheets-formulagoogle-sheets-query

Google Sheets formula to calculate sum of values in one column which match multiple columns in another sheet


I need a formula in Sheet 2 column D which will look up the values of columns B and C in Sheet 1 column A and calculate the sum of the values in column C. So for example, D2 will return 36.

Sheet 1: sheet1

Sheet 2 enter image description here


Solution

  • =ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, QUERY({Sheet1!B:C}, 
     "select Col1, sum(Col2) where Col1 != '' group by Col1", 0), 2, 0)))
    

    0