revenue_by_period
Calculate revenue by year or month, excluding cancelled orders, to analyze sales trends over a specified date range.
Instructions
Revenue (sum of orders.total_amount) EXCLUDING cancelled orders, grouped by period. group_by = "year" (default) or "month" (-> YYYY-MM). Returns rows sorted by period ascending; a period with no data simply yields no row. Each row: { period, revenue }.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Only include orders with order_date <= this ISO date/datetime. | |
| from | No | Only include orders with order_date >= this ISO date/datetime. | |
| group_by | No | Grouping period: 'year' (YYYY) or 'month' (YYYY-MM). Default 'year'. |