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
| Argument | Required | Meaning |
|---|---|---|
| row_fields | Yes | Column or columns whose values define row groups. |
| values | Yes | Numeric data to summarize, aligned with the grouping fields. |
| function | Yes | The aggregation function or LAMBDA used for each group. |
| field_headers | No | Controls whether input headers exist and whether headers are returned. |
| total_depth | No | Controls the depth of subtotals and grand totals in the grouped result. |
| sort_order | No | Controls the grouping or value columns used to order the result. |
| filter_array | No | A Boolean filter aligned with source records; only included records are summarized. |
| field_relationship | No | Controls whether multiple grouping fields are treated hierarchically or as separate fields. |
Try GROUPBY
Put the table grand total before independently sorted keys
=GROUPBY(A1:B7,C1:C7,SUM,3,-1,{2,-1},D1:D7,1)Table mode supports a grand total but has no parent hierarchy for subtotals. total_depth=-1 places the sum 18 above the detail rows. Team sorts ascending, then Region descending across complete keys. Positive and negative source units remain in each sum.
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(A1:B7,C1:C7,SUM,3,-1,{2,-1},D1:D7,1)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.