Formula guide · Google Sheets · Updated May 13, 2026

QUERY Group By in Google Sheets

Group rows and summarize values in Google Sheets with QUERY group by.

Quick Answer

Use group by when you want one summary row per category.

Copyable Formula

=QUERY(A1:D20,"select A, sum(D) group by A label sum(D) 'Total'",1)

Syntax

=QUERY(A1:D20,"select A, sum(D) group by A",1)

Google Sheets

Worked Example

AD
RegionAmount
West120
East90
West80

Result: Returns one row for each region with total amount.

Steps

  • Select the grouping column and the aggregate measure.
  • Use group by with every non-aggregated selected column.
  • Add label to rename aggregate columns.

Common Mistakes

  • Selecting non-aggregated columns that are not in group by.
  • Grouping a column with inconsistent labels such as West and west.
  • Using group by when a pivot table would be easier for non-technical users.

Excel vs Google Sheets Notes

This page is focused on Google Sheets. Excel may require a different function, pivot table, or Power Query workflow.

Editorial check: This guide was last updated May 13, 2026. Formula behavior can vary by Excel version, Google Sheets rollout, and spreadsheet locale.

FAQ