Business KPIs
get_kpiCalculate a business KPI (revenue, top products or customers, average order value, overdue receivables) for a date range, optionally compared with the previous equivalent period.
Instructions
Calculate a business KPI for a date range from a fixed list of metrics.
Use for "How did revenue this quarter compare to last quarter?", "Top 5 products last month", "Average order value in 2026" or "How much is overdue?". Example: metric='revenue', period_start='2026-10-01', period_end='2026-12-31', compare_previous=true. Partial periods include a like-for-like comparison.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Number of items for top_* metrics. | |
| metric | Yes | revenue = invoiced sales; top_products / top_customers = ranking by revenue; avg_order_value = revenue per invoiced order; overdue_receivables = unpaid past-due invoices as of period_end, with aging buckets. | |
| period_end | Yes | Last day of the period, YYYY-MM-DD (inclusive). | |
| period_start | Yes | First day of the period, YYYY-MM-DD. | |
| compare_previous | No | Also return the previous period and % change. Calendar months, quarters and years compare with the previous calendar month/quarter/year; other ranges with the same-length window before. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||