Skip to main content
DocsCML Reference

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

TypeFormatExample
integer1,2344,521
float1,234.5642.38
currency$1,234$42,381
percentage12.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.