Google-sheets – Collecting a sum of data until another name is mentioned

google sheets

Every day I get a spreadsheet of info for all members of the company. Its broken down by employee, then the store that the employee worked in. The problem is, the cells with the employee name is merged so I can't just sumif the name is right. So I need to sumif for the name, then the empty cells below it until there's another name.

Example:

Name 1  Store 1   4
        Store 2   5
        Store 3   2
Name 2  Store 1   3
        Store 2   4

So what I'm trying to get is the total for Name 1, which in this example would be 11.

Best Answer

Use this formula

=query({query(ArrayFormula(vlookup(ROW(1:5),{IF(LEN(A1:A5)>0,ROW(1:5),""),A1:A5},2)),"select Col1"),query(B1:C5,"select B, C")}, "select Col1, sum(Col3) group by Col1 label Sum(Col3) ''")


The answer to this question comprises 3 elements.

  • Populate the empty names in Column A

  • Create a query to combine the newly populated column A with the existing Column B and Column C

  • In the query, modify the select clause to display the sum of Column C grouped by Name