Formualizer Docs
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_fields and values must 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
CellValue
Formula
=
Result
Not evaluated yet.
Expected
[["Region","Sales"],["East",150],["West",80]]
Average with grand total
Grid
CellValue
Formula
=
Result
Not evaluated yet.
Expected
Grouped table with team averages plus grand total row

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-ref

Range · Range

arg2by-ref

Range · Range

arg3

Any · Scalar

arg4optionaldefault

Number · Scalar · coercion NumberLenientText

arg5optionaldefault

Number · Scalar · coercion NumberLenientText

arg6optionaldefault

Number · Scalar · coercion NumberLenientText

Caps

PURE

Source

On this page