Skip to main content
← All functions

GROUPBY function

Summarize values by one or more grouping fields.

Group selected source records with a named aggregation or local LAMBDA. The eighth field_relationship argument chooses hierarchy (0/default) or table (1). Hierarchy sorting stays within parent groups and automatic totals include available subtotals; table sorting orders complete keys globally and supports grand totals only. Examples also cover signed sums, means, reducer vectors, headers and measure sorting. Native Excel recalculation and complete layout/coercion parity remain unverified.

Syntax

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

Square brackets indicate optional arguments.

Arguments

ArgumentRequiredMeaning
row_fieldsYesColumn or columns whose values define row groups.
valuesYesNumeric data to summarize, aligned with the grouping fields.
functionYesThe aggregation function or LAMBDA used for each group.
field_headersNoControls whether input headers exist and whether headers are returned.
total_depthNoControls the depth of subtotals and grand totals in the grouped result.
sort_orderNoControls the grouping or value columns used to order the result.
filter_arrayNoA Boolean filter aligned with source records; only included records are summarized.
field_relationshipNoControls whether multiple grouping fields are treated hierarchically or as separate fields.

Try GROUPBY

Average each selected group over its original observations

=GROUPBY(A2:A6,B2:B6,AVERAGE,0,0,1,C2:C6="Posted")

AMBER has two selected observations, 6 and -2, giving mean 2. BLUE has one actual zero, giving mean 0. The excluded rows do not enter the counts or introduce groups.

Inspect the current formula

Read its written arguments or observe actual operation values in a separate local calculation. This action neither applies a draft nor grades an answer.

Read the formula, one argument at a time

Explore the written function calls and their inputs. The calculation result belongs to the complete formula.

GROUPBY · top-level call

=GROUPBY(A2:A6,B2:B6,AVERAGE,0,0,1,C2:C6="Posted")

1 / 7 · row_fields

Column or columns whose values define row groups.

GROUPBY reference ↗

Follow the cells behind a result

Read explicit local references and helper formulas using a separate calculation. Your draft stays in this field; the worksheet and practice checks do not change.

The worksheet runs locally. Published checks apply to the supplied example only. Native Excel and Google Sheets compatibility remain unverified.

Practice a complete task

Reference and compatibility

Original SheetTutor reference notes / Microsoft documentation. Calculation checks cover the supplied examples only. The browser worksheet does not implement every Excel feature, external service or connected data type.