explain_change
Explain WHY a number changed between two periods: the change split by a dimension (status, technician, service type, customer…), biggest movers first, with values that appeared or disappeared flagged. Give the table, the metric (a count, or the sum or average of a numeric column), the dimension, the date column that places each row in a period, and the baseline (period_a) and comparison (period_b) windows. Try another dimension when the first doesn't explain it.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| label | No | Optional title for the driver table (e.g. 'What drove the revenue drop'). | |
| limit | No | How many top drivers to show (default 12, max 50). | |
| table | Yes | The table to analyze (a read-allowlisted table). | |
| metric | Yes | What to measure: { agg: 'count' | 'sum' | 'avg', column? }. Use count for record volume; sum/avg require a numeric column (e.g. { agg:'sum', column:'total_amount' }). | |
| filters | No | Optional equality filters applied to BOTH periods, each { column, value } (e.g. narrow to one branch). Values are matched exactly. | |
| period_a | Yes | The BASELINE window { from, to } as YYYY-MM-DD (from inclusive, to exclusive). This is the 'before'. | |
| period_b | Yes | The COMPARISON window { from, to } as YYYY-MM-DD. This is the 'after' — the change is B minus A. | |
| dimension | Yes | The column to break the change down by (e.g. 'status', 'technician_name', 'service_type'). Each distinct value becomes a driver row. | |
| date_column | Yes | The date/timestamp column that places each record into a period (e.g. 'created_at', 'scheduled_date'). |