Metrics
Metrics are specific calculations that need to be exactly right every time. While instructions give Qluent the background context, metrics define how to calculate your key numbers.
When a user asks a question that matches a metric, Qluent uses your exact SQL—ensuring the calculation is always correct. A verification badge is displayed so users know the answer follows your business definitions.
Use case
Some calculations need to be consistent across all reports:
- Revenue must exclude refunds and use correct tax treatment
- Customer lifetime value has a specific formula your team agreed on
- Conversion rates must match your other reporting tools
Metrics ensure these calculations stay the same, even when Qluent adapts them for different filters or groupings.
How it works
- You define a metric with a name and SQL query
- When a user asks a related question, Qluent finds the matching metric
- Qluent adapts your SQL (adding filters, groupings) while keeping the core calculation
- Users see the verified badge
Example
Metric:
Name: Total Revenue
SELECT SUM(order_total - refund_amount) as revenue
FROM orders
WHERE status = 'completed'
User asks: "What's our revenue by product category?"
Qluent adapts:
SELECT category, SUM(order_total - refund_amount) as revenue
FROM orders
WHERE status = 'completed'
GROUP BY category
The grouping is added, but the revenue calculation (order_total minus refunds, only completed orders) stays exactly the same.
Creating metrics
Add a short name and the SQL code that answers it. Qluent adapts the SQL to different questions, so you don't need to provide all variations.
Tips
- Keep SQL simple - Let Qluent handle variations
- One metric per concept - Don't combine multiple KPIs in one metric
- Use business-friendly names - "Monthly Revenue" not
sum_order_total_monthly - Add comments for complex logic - Helps Qluent understand the intent
Example metrics
- Total Revenue (excluding refunds and cancellations)
- Customer Lifetime Value (LTV)
- Conversion Rate
- Monthly Active Users (MAU)
- Average Order Value
Validation
Qluent validates metrics against your data model:
- All referenced tables must exist and be enabled
- All referenced columns must exist and be enabled
- SQL must be valid
If validation fails, the metric won't be used. If your data model changes (tables renamed, columns removed), revalidate your metrics.
Metrics vs validated queries
| Metrics | Validated Queries |
|---|---|
| Define specific calculations | Teach query patterns |
| Used directly when matched | Influence how new queries are written |
| For KPIs that must be exact | For showing how to join tables, filter data, etc. |
Use metrics when a calculation must be exactly right. Use validated queries to teach Qluent how to write queries for your data.