Search code examples
arraysexcel-formulasumgoogle-sheets-formulagoogle-query-language

Google sheets sum two columns based off of different variables sorted by variables


I have a list of items that are in two distinct columns, with different values in each. The columns are not sorted and are about 15000 lines long each. There are items in Column A, that will not be present in column C, and vice versa. Check here for reference on what I'm talking about. I need to get the sum of columns B and E, sorted by columns A and D, like you can see on sheet 2. Is there a convenient way to go about this?


Solution

  • use:

    =QUERY({A:B; D:E}, 
     "select Col1,sum(Col2) 
      where Col2 matches '\d+'
      group by Col1 
      label sum(Col2)'Total'")
    

    enter image description here