
Google Sheets QUERY function is a powerful alternative to Excel’s PivotTables. It offers dynamic pivot table-like analysis of data without requiring constant manual updates. Excel’s PivotTables are one of the most powerful features for data analysis, it offers advanced features and options. This post will show you how to use the Google Sheets QUERY function and Excel’s PivotTables to perform similar tasks while comparing them.
What is the QUERY Function in Google Sheets?
The QUERY function allows you to run SQL-like queries on your data range to manipulate data. SQL queries can filter, sort, group, and aggregate data without needing to manually reorganize the table as you would in PivotTables. It can perform pivot table-like analysis by using all clauses. It has a dedicated PIVOT clause to transpose unique values from rows into columns and allows you to combine it with other clauses like SELECT, GROUP BY, etc.
Syntax:
=QUERY(data, query, [headers])
- data: The range of cells to perform the query on.
- query: SQL-like queries to extract information from your data range.
- [headers]; [Optional]: It indicates the number of header rows at the top of the data.
What is PivotTables in Excel?
Excel’s PivotTables offers a dedicated PivotTable Analyze tab that allows users to drag and drop fields to create a summary without writing formulas. It offers built-in features for quick analysis of simple to advanced data.
Using Google Sheets’ QUERY Function and Excel’s PivotTables for Pivot Table-like Analysis
Let’s imagine you have sales data where you want to summarize the sales amount and quantity by category. Now let us show you the use of the QUERY function in Google Sheets where we will replicate common PivotTable functionalities.
Sample Dataset:
| Employee Name | Date | Product | Category | Quantity | Sales Amount |
| Mike Jonas | 01/01/2024 | Laptop | Electronics | 4 | $2,200.00 |
| Steve Smith | 03/01/2024 | Smartphone | Electronics | 5 | $800.00 |
| Lara Jonson | 03/01/2024 | TV | Electronics | 3 | $1,500.00 |
| Emily Copper | 07/01/2024 | Headphones | Electronics | 1 | $100.00 |
| Mike Jonas | 07/01/2024 | Book | Books | 8 | $200.00 |
| Sarah Lee | 15/01/2024 | Chair | Furniture | 2 | $200.00 |
| Steve Smith | 15/01/2024 | Table | Furniture | 4 | $300.00 |
| Emily Copper | 18/01/2024 | Jacket | Clothing | 12 | $80.00 |
| Elian Swift | 18/01/2024 | Shoes | Clothing | 7 | $120.00 |
| Mike Jonas | 20/01/2024 | Book | Books | 4 | $180.00 |
Google Sheets’ QUERY Function:
You can use the QUERY function to summarize the sales amount and quantity by different categories. Insert the following formula in the Cell H1.
Formula:
=QUERY(A1:F11, “SELECT D, SUM(E), SUM(F) GROUP BY D”, 1)
Explanation:
- SELECT D: Select all values from column D (Category).
- SUM(E), SUM(F): This sums the values of column E (Quantity) and column F (Sales Amount)
- GROUP BY D: This groups the results by category of column D, so the data is aggregated by the unique values in that column.
- 1: The number of header rows at the top of sales data. To ignore the first row when performing calculations.
Output:
| Category | sum Quantity | sum Sales Amount |
| Books | 12 | 380 |
| Clothing | 19 | 200 |
| Electronics | 13 | 4600 |
| Furniture | 6 | 500 |
Excel PivotTables:
Now, you can perform a similar task by using the PivotTables in Excel. Follow the following steps to do so:
- Select the data range >> go to Insert tab >> select PivotTable.

- In PivotTable from table or range, select Existing Worksheet >> location Sheet3!$H$1 >> click on OK.

- Now, drag the Category in the Rows field and Quantity and Sales Amount in the Values field.

Here is a quick summary of sales and quantity for each category.
Conclusion
Both have different functionalities and features but the QUERY function in Google Sheets offers pivot table-like analysis for dynamic, real-time data analysis. It can perform multiple tasks within a single formula that gives more control over data manipulation. But you will need the knowledge of SQL queries. Excel’s PivotTable drag-and-drop functionality helps to easily add or remove fields. Its layout offers more advanced options for aggregations but it requires manual updates when the main table data is updated. Mastering the QUERY function in Google Sheets will create new possibilities to perform pivot table-like analysis.
