Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove zero rows from Google Sheets pivot table

I have a pivot table to aggregate some financial balance by counterparties. Link to the example.

Over time, it's expected that the aggregate amount for most of the parties will be 0. I want to show only those rows in the pivot table where the aggregate is nonzero. Otherwise, my pivot table will be cluttered by tons of empty zero rows.

In the above example, this corresponds to hiding John, Mary, and Thomas records.

Is there a way to accomplish this?

like image 666
Samuel Hapak Avatar asked Aug 06 '26 09:08

Samuel Hapak


2 Answers

You can achieve this by adding a filter on top of your pivot table.

  1. Select the row with currencies (2nd row of pivot table)
  2. Data->Create a filter...
  3. Click on the last column
  4. Filter by condition...->Custom formula is
  5. =ABS(B3) + ABS(C3) + ABS(D3) > 0

See the example.

like image 74
Samuel Hapak Avatar answered Aug 09 '26 10:08

Samuel Hapak


you could use a double query like:

=QUERY(QUERY(Transactions!A1:C, 
 "select A,sum(B) 
  where A is not null 
  group by A 
  pivot C", 1),
 "where Col2>0 
     or Col3>0 
     or Col4>0", 1)

0

like image 44
player0 Avatar answered Aug 09 '26 10:08

player0