add_metric
Define a reusable SQL aggregate metric (KPI) like revenue or default rate for quantitative analysis. Returns the metric's ID and name.
Instructions
Define a metric: a named, reusable SQL aggregate (a KPI).
Use for quantitative measures like revenue or default rate so grounding and generation can reuse them; for phrase-to-SQL mappings use add_glossary_term instead. Returns the new metric's id and name.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connection | Yes | Target database connection — its name or id (case-insensitive). List the available connections with list_connections. | |
| metric_name | Yes | Machine-friendly metric identifier (e.g. 'gross_revenue'). | |
| display_name | Yes | Human-friendly metric label (e.g. 'Gross Revenue'). | |
| sql_expression | Yes | SQL aggregate expression implementing the metric (e.g. SUM(amount)). | |
| description | No | Optional explanation of what the metric measures. | |
| related_tables | No | Optional list of table names the metric is computed from. | |
| dimensions | No | Optional dimensions to group the metric by (e.g. ['region','month']). |