CML — Metrics reference
Metrics are aggregation expressions defined in node files.
Supported aggregations
# Count rows
- name: payment_count
sql: COUNT(*)
type: integer
# Count distinct values
- name: unique_customers
sql: COUNT(DISTINCT customer_id)
type: integer
# Sum
- name: total_revenue
sql: SUM(amount)
type: currency
# Average
- name: avg_payment
sql: AVG(amount)
type: float
# Min / Max
- name: first_payment
sql: MIN(payment_date)
type: date
# Custom expression
- name: revenue_per_customer
sql: SUM(amount) / NULLIF(COUNT(DISTINCT customer_id), 0)
type: currency
Metric types
| Type | Format | Example |
|---|---|---|
integer | 1,234 | 4,521 |
float | 1,234.56 | 42.38 |
currency | $1,234 | $42,381 |
percentage | 12.3% | 87.4% |
Metric in context
Metrics are always evaluated in the context of the query's GROUP BY clause. Celiq builds the GROUP BY from the selected attributes automatically.