Search code examples
arraysgoogle-sheetsgoogle-sheets-formulagoogle-sheets-querygoogle-query-language

Google Sheet Query SUM exclude IF is not blank


In the tab "Invoice WholeSale", cell "B3" I need a query to SUM the tabs:

  • "Stock Warehouse Moves"
  • "Stock Shop Moves "

but grouped by the column WholeSale and IGNORE the rows without text in this column.

here is my Google sheet

For exmaple I expect from tab:
"Stock Warehouse Moves"

0

and from tab
"Stock Shop Moves"

0

I try this but doesn't work:

=query('Stock Warehouse Moves'!A3:I,"select H, sum(B) where (H is not null) group by H"{'Stock Shop Moves'!A3:I,"select H, sum(B) where (H is not null) group by H"})

and this, but doesn't show the data properly:

=query('Stock Shop Moves'!A3:I,"select H, sum(B) where (H is not null) group by H")

I expected the next grouped by WholeSale:

0


Solution

  • try like this:

    =QUERY({'Stock Warehouse Moves'!A3:H; 'Stock Shop Moves'!A3:H},
     "select Col1,count(Col8),Col8 
      where Col8 is not null 
      group by Col1,Col8 
      label count(Col8)''", 0)
    

    0