2, "↑", "↓")), PERCENTOF): Performs COUNT calculation on the Sales column (count analysis) Applies LAMBDA formula on the Ratings column to display "↑" if count is greater than 2 or "↓" otherwise Performs PERCENTOF calculation on the Profit column (percentage analysis) Sets parameter total_depth to 0 (no totals)"/>
GROUPBY Function
Refer to the following examples to see how to use the GROUPBY function to perform data aggregation using a single formula:
- J3 cell formula: `=GROUPBY(A1:B62, E1:E62, SUM, 3, 2)`
- Uses A1:B62 range (Year and Category) as parameter **row_fields**
- Selects E1:E62 range (Sales) as parameter **values** for aggregation
- Applies SUM aggregation as parameter **function** to the Sales column
- Sets parameter **field_headers** to 3 (show field headers)
- Sets parameter **total_depth** to 2 (show both grand totals and subtotals)
- P3 cell formula: `=GROUPBY(B1:B62, E1:G62, VSTACK(COUNT, LAMBDA(a, IF(COUNT(a)>2, "↑", "↓")), PERCENTOF), , 0)`
- Uses B1:B62 range (Category) as parameter **row_fields**
- Selects E1:G62 range (Sales, Rating, Profit) as parameter **values** for aggregation
- Applies aggregation parameter **function** to the selected values using VSTACK(COUNT, LAMBDA(a, IF(COUNT(a)>2, "↑", "↓")), PERCENTOF):
- Performs COUNT calculation on the Sales column (count analysis)
- Applies LAMBDA formula on the Ratings column to display "↑" if count is greater than 2 or "↓" otherwise
- Performs PERCENTOF calculation on the Profit column (percentage analysis)
- Sets parameter **total_depth** to 0 (no totals)