Appearance
dbt metrics
If your dbt project defines metrics for MetricFlow, you can chart them without writing SQL. In the chart editor, switch the query to dbt Metric, pick a metric and, optionally, a dimension to group by.
Diver writes the metric as DQL from its definition in dbt, each time the chart runs. A chart therefore shows the same numbers as dbt does, and follows changes to the metric once Diver has synced the dbt project again.
Filters
A metric chart follows the dashboard's filters like any other chart:
- The time range filters the metric by its time dimension, the semantic model's
agg_time_dimension. - Grouped by a time dimension, the chart follows the aggregation filter, unless a grain such as
monthis picked for it.
For a metric of orders, grouped by its time dimension and by country, Diver writes:
sql
select {metric_time:aggregation} as metric_time, country, sum(diver_measure_1) as revenue
from (
select
ordered_at as metric_time,
country,
amount as diver_measure_1
from "analytics"."marts"."fct_orders"
) as diver_metric_rows
where {metric_time=timerange}
group by 1, 2
order by 1, 2
limit 500Dimensions
Name a dimension as MetricFlow does: metric_time for the metric's time dimension, order__country with the entity, or just country. A time dimension can be followed by a grain, as in metric_time__month.
In a dashboard file
A chart in a *.diver.yml file charts a metric by its name in dbt:
yaml
dataset:
source: warehouse-prod
metric: revenue
dimensions: [metric_time__month, order__country]What Diver supports
| Metric | Supported |
|---|---|
Simple metrics, with every aggregation (sum, count, count_distinct, average, min, max, sum_boolean, median and percentile) | Yes. MySQL has no percentiles. |
| Ratio and derived metrics | Yes, when the metrics they're built from are in the same semantic model |
Metric filters, such as {{ Dimension('order__is_food_order') }} | Yes |
Derived metrics with offset_window or offset_to_grain | Not yet |
| Cumulative and conversion metrics | Not yet |
Semi-additive measures (non_additive_dimension) | Not yet |
| Dimensions of other semantic models, which MetricFlow joins | Not yet |