[]
        
(Showing Draft Content)

PIVOTBY

This function is a powerful tool that allows you to create a summary of your data using a formula. It supports grouping along two axes and aggregating the associated values. This function is like the GROUPBY function but with the added capability of grouping data by both rows and columns.

Note: PIVOTBY is a dynamic array formula, and you need to enable the dynamic array feature in the Workbook.

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])

Arguments

The function has following arguments.

Arguments

Description

row_fields

[Required] A column-oriented array or range that contains the values used to group rows and generate row headers.

col_fields

[Required] A column-oriented array or range that contains the values used to group columns and generate column headers.

values

[Required] A column-oriented array or range of the data to aggregate.

function

[Required] A lambda function or eta reduced lambda (e.g., SUM, AVERAGE, COUNT) that defines how to aggregate the values.

field_headers

[Optional] Specifies whether the row_fields, col_fields, and values have headers and whether field headers should be returned in the results.

row_total_depth

[Optional] Determines whether the row headers should contain totals.

row_sort_order

[Optional] Indicates how rows should be sorted.

col_total_depth

[Optional] Determines whether the column headers should contain totals.

col_sort_order

[Optional] Indicates how columns should be sorted.

filter_array

[Optional] A column-oriented 1D array of Booleans that indicate whether the corresponding row of data should be considered.

relative_to

[Optional] Controls which values are provided to the second argument of the aggregation function, typically used with the PERCENTOF function.

Remarks

  • PIVOTBY function supports Excel import and export.

  • PIVOTBY is a dynamic array function which automatically spills the results into as many cells as needed.

Example

PIVOTBY (B2:B34,A2:A34,D2:D34,SUM)