group_by_aggregate
Group records by a field and aggregate another field per group using sum, avg, min, max, or count. Returns sorted results with optional limit for quick subtotals.
Instructions
Group records by a field and aggregate another field per group. Like a SQL GROUP BY or Excel pivot. Returns sorted results with optional limit. Use for subtotals by supplier, business unit, status, etc.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"records": "<records>",
"group_field": "<group_field>",
"agg_field": "<agg_field>"
},
"name": "group_by_aggregate"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max number of groups to return (e.g. top 10). | |
| records | Yes | Array of record objects. | |
| sort_by | No | Sort order (default: value_desc = highest first). | value_desc |
| agg_field | Yes | Field to aggregate within each group. | |
| operation | No | Aggregation operation (default: sum). | sum |
| group_field | Yes | Field to group by (e.g. 'SupplierName', 'BusinessUnit'). | |
| decimal_places | No |