Excel GROUPBY function

Groups and summarizes data with a single formula: a pivot table that updates by itself. In Spanish Excel it is called AGRUPARPOR.

Syntax

English Excel

=GROUPBY(row_fields, values, function, [field_headers], [total_depth], [sort_order], [filter_array])

Spanish Excel (Mexico)

=AGRUPARPOR(campos_de_fila, valores, función, [encabezados_de_campo], [profundidad_total], [orden_de_clasificación], [matriz_de_filtro])

Spanish Excel (Spain, Latin America)

=AGRUPARPOR(campos_de_fila; valores; función; [encabezados_de_campo]; [profundidad_total]; [orden_de_clasificación]; [matriz_de_filtro])

ArgumentWhat it is
row_fieldsThe column (or columns) to group by.
valuesThe numbers to summarize.
functionSUM, AVERAGE, COUNT, MAX… written without parentheses, or a LAMBDA.
field_headersoptional0 no headers, 1 has them but hides them, 3 has and shows them.
total_depthoptional0 no total, 1 total at the bottom, -1 total at the top.
sort_orderoptionalThe column number to sort by; negative is descending.
filter_arrayoptionalA condition to include only some rows.

Example

GROUPBY(row_fields, values, function) groups repeated values and summarizes them with the function you pass by name: SUM, AVERAGE, COUNT, MAX… It adds a Total row and sorts by the first column. Optional arguments change headers, totals and order.

=GROUPBY(A2:A13,C2:C13,SUM)

Common mistake

Excel 365 only. The function goes without parentheses: GROUPBY(A2:A50,C2:C50,SUM). For rows and columns at once use PIVOTBY.

About Ads

This site uses Google AdSense to display ads. These ads help us keep WebHerramientas completely free. Ads are managed by Google and meet strict security and privacy standards.

Advertising
Loading ad...

Ads help us keep WebHerramientas free for everyone

Practice GROUPBY

Type the formula in the sheet and check it instantly. Spanish or English function names both work. See all lessons

GROUPBY: a pivot table in one formula

GROUPBY(row_fields, values, function) groups repeated values and summarizes them with the function you pass by name: SUM, AVERAGE, COUNT, MAX… It adds a Total row and sorts by the first column. Optional arguments change headers, totals and order.

Example=GROUPBY(A2:A13,C2:C13,SUM)AGRUPARPOR = GROUPBY
Step 1/2

In E2, summarize the total amount by region with GROUPBY.

E2
ABCDEFGHIJ
1RegionRepAmountTotal by regionAverage by rep
2NorthAna12,400.00
3SouthBeto8,300.00
4CentralCarla15,600.00
5NorthDani9,100.00
6SouthAna11,200.00
7CentralBeto7,400.00
8NorthCarla13,800.00
9SouthDani6,900.00
10CentralAna10,500.00
11NorthBeto8,800.00
12SouthCarla14,200.00
13CentralDani9,700.00
14

Tip: while typing, click a cell or drag across several to insert their reference. F4 anchors the reference with $.

Frequently asked questions

What is GROUPBY called in Spanish?
In Spanish Excel it is AGRUPARPOR. The formula =GROUPBY(A2:A13,C2:C13,SUM) is written =AGRUPARPOR(A2:A13;C2:C13;SUMA) (or with commas in Mexico).
Why does GROUPBY use semicolons in some Excel versions?
It depends on regional settings. Where the comma is the decimal mark (Spain, much of South America), Excel separates arguments with semicolons. English Excel and Mexican Spanish Excel use commas.
What is the most common GROUPBY mistake?
Excel 365 only. The function goes without parentheses: GROUPBY(A2:A50,C2:C50,SUM). For rows and columns at once use PIVOTBY.