HomeGoogle DocsSpreadsheetExtract Total and Grand Total Rows From a Pivot Table in Google...

Extract Total and Grand Total Rows From a Pivot Table in Google Sheets

Published on

It’s almost impossible to extract total and grand total rows from a Pivot table report using the GETPIVOTDATA function in Google Sheets. But there is an alternative formula.

Of course, to dynamically pull aggregated values from a Pivot table, including from a total row, you can use the GETPIVOTDATA function. 

But with this function, you can’t pull an entire total row without nesting it.

For example, see the below nested GETPIVOTDATA formula in cell E12 and the pivot table report in A1:D12.

={"Grand Total",GETPIVOTDATA("Sum of Total Sales",A1),GETPIVOTDATA("Average of Total Sales",A1)}
Extract Total and Grand Total Rows From a Pivot Table

The formula successfully extracts the grand total row.

But what about including the subtotal rows? I mean the “Jeanne Total” and “Matt Total” rows.

The GETPIVOTDATA nested formula will become very complicated. Please see the example below.

={"Jeanne Total",GETPIVOTDATA("Sum of Total Sales",A1,"Name","Jeanne"),GETPIVOTDATA("Average of Total Sales",A1,"Name","Jeanne");{"Matt Total",GETPIVOTDATA("Sum of Total Sales",A1,"Name","Matt"),GETPIVOTDATA("Average of Total Sales",A1,"Name","Matt")};{"Grand Total",GETPIVOTDATA("Sum of Total Sales",A1),GETPIVOTDATA("Average of Total Sales",A1)}}

You can ignore this formula. You can’t call this a dynamic formula because, for each total row, you must nest the formula.

That means you can’t use the GETPIVOTDATA function dynamically to extract the individual totals and grand total rows from a Pivot table.

Instead, you can use a FILTER + SEARCH combo, which is dynamic.

When the source changes, the total rows may move up or down. My formula is ready to accommodate those changes.

Let’s consider a small dataset (sales report of two employees).

Sales Report Mock-up for Pivot Table

Here are the Pivot table settings used to generate the above Pivot table report.

Total Settings for a Pivot Table to Extract Total Rows

As a side note, to access the Pivot table editor, go to the Insert menu Pivot table.

Formula to Extract the Total Rows From a Pivot Table Report in Google Sheets

The following Filter + Search combo will pull the subtotal and total rows from the above Pivot table.

=filter(A1:D,search("Total",A1:A)>1)

It’s a very clean formula compared to the GETPIVOTDATA one above. It’s also dynamic.

Formula Output:

Jeanne Total$15,200.00$3,800.00
Matt Total$14,000.00$3,500.00
Grand Total$29,200.00$3,650.00

Why should I call it dynamic?

For example, assume you have added one more employee to your sales report.

The formula will include that person’s total also in the extracted output.

How to Use the Filter + Search Combo in Pivot Table to Pull Data

The FILTER function is handy to use to filter a table with conditions. You can use this function in a Pivot table too.

FILTER(range, condition1, [condition2, ...])

I have used the Search formula to feed the Filter criterion/condition1. It is because I want to do a partial match.

I want to filter rows in the Pivot table column A that contain the string ‘Total.’

That’s why I have used the Search function within Filter.

The Search function will return a numeric number if the string ‘Total’ is available in a row. So the criterion will be;

search("Total",A1:A)>1

Some of you may ask about the possibility of using any wildcard characters within the Filter. The answer is NO. That’s why I have used the Search function.

That’s all about extracting total rows dynamically from a Pivot table in Google Sheets.

I hope you have enjoyed this tutorial. See you next time with another Google Sheets tutorial.

Similar Tutorials:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Converting a Range to a Table and Vice Versa in Google Sheets

Google Sheets has recently introduced several features, with one of the latest being the...

EXPAND + Stacking: Expand an Array in Excel

We can expand an array by adding values at the end using the EXPAND...

Convert Month Name to Days in Google Sheets

We can utilize the EOMONTH, MONTH, DATE, and DAY functions in Google Sheets to...

Creating Custom Descending Sequence Lists in Excel

You can utilize functions like ROW or SEQUENCE in Excel to create a custom...

More like this

Converting a Range to a Table and Vice Versa in Google Sheets

Google Sheets has recently introduced several features, with one of the latest being the...

Convert Month Name to Days in Google Sheets

We can utilize the EOMONTH, MONTH, DATE, and DAY functions in Google Sheets to...

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.