15.1 C
London
Friday, July 5, 2024
HomeSoftware TutorialsGoogle SheetsGoogle Sheets Query: How to Create a Pivot Table

Google Sheets Query: How to Create a Pivot Table

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

You can use the following syntax to create a pivot table using Google Sheets Query:

=query(A1:C13, "select A, sum(C) group by A pivot B")

In this example, we choose column A to represent the rows of the pivot table, column B to represent the columns of the pivot table, and the values in column C to be displayed inside the pivot table.

The following examples show how to use this syntax in practice.

Example 1: Create a Pivot Table Using SUM()

We can use the following formula to create a pivot table that displays the total sales by product and by region for a certain company:

We would interpret the values in the pivot table as follows:

  • The total sales of product A in the East region was 388.
  • The total sales of product B in the East region was 0.
  • The total sales of product C in the East region was 476.
  • The total sales of product D in the East region was 0.

And so on.

Example 2: Create a Pivot Table Using AVG()

We can use the following formula to create a pivot table that displays the average sales by product and by region for a certain company:

We would interpret the values in the pivot table as follows:

  • The average sales of product A in the East region was 388.
  • The average sales of product B in the East region was 0.
  • The average sales of product C in the East region was 238.
  • The average sales of product D in the East region was 0.

And so on.

Additional Resources

Google Sheets Query: How to Select Multiple Columns
Google Sheets Query: How to Use Group By
Google Sheets Query: How to Use Order By

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories