ReferenceFunctionsLookup Functions
GROUPBY
GROUPBY: Groups rows by key fields and returns aggregated values as a spilled table.
Summary
GROUPBY summarizes one or more value columns using a selected aggregation function.
Remarks
row_fieldsandvaluesmust have the same row count.- Aggregation can be supplied as text (for example
"SUM") or numeric code. - Optional controls:
field_headers,total_depth,sort_order. - Invalid aggregation names/codes return
#VALUE!. - Output is dynamic-array shaped and may include generated headers or totals.
Examples
Sum sales by region
Grid
| Cell | Value | |
|---|---|---|
Formula
=
Result
Not evaluated yet.
Expected
[["Region","Sales"],["East",150],["West",80]]
Average with grand total
Grid
| Cell | Value | |
|---|---|---|
Formula
=
Result
Not evaluated yet.
Expected
Grouped table with team averages plus grand total row
Related functions
FAQ
What shape constraints does GROUPBY enforce?
row_fields and values must have the same number of rows; mismatched heights return #VALUE!.
Can the aggregation function be numeric instead of text?
Yes. GROUPBY accepts either function names (like "SUM") or numeric function codes, and invalid entries return #VALUE!.
Runtime metadata
Category
Lookup
Signature
GROUPBY(arg1: Range (Range), arg2: Range (Range), arg3: Any, arg4?: Number, arg5?: Number, arg6?…: Number)Arity
min 3, max variadic
Arguments
arg1by-refRange · Range
arg2by-refRange · Range
arg3Any · Scalar
arg4optionaldefaultNumber · Scalar · coercion NumberLenientText
arg5optionaldefaultNumber · Scalar · coercion NumberLenientText
arg6optionaldefaultNumber · Scalar · coercion NumberLenientText
Caps
PURE
Source