Lookup & reference

PIVOTBY function

Aggregate values by row and column groups. PIVOTBY works in Sheets with the usual arguments and results, on cells and on live data from the tools you connect.

Syntax

=PIVOTBY(row_fields, col_fields, values, function, [field_headers], [row_total_depth], [row_sort_order], [col_total_depth], [col_sort_order], [filter_array], [relative_to])
ArgumentUse
row_fieldsrequired
col_fieldsrequired
valuesrequired
functionrequired
field_headersoptional
row_total_depthoptional
row_sort_orderoptional
col_total_depthoptional
col_sort_orderoptional
filter_arrayoptional
relative_tooptional

On live data

In Sheets, PIVOTBY sits next to live data from a connected tool: =data.orders.sum(total) totals a table, =list.orders(customer) spills a column's distinct values, and a linked table column such as table.orders[Total] is a range any function accepts.

See the integrations

More lookup & reference functions

All 37 lookup & reference functions →

Spreadsheet formulas on live business data

Sheets evaluates 491 spreadsheet functions, on cells and on data read live from your tools.