A Shared Metric Set

A Shared Metric Set for BookNest's Sales Mart

BookNest's metrics live in the dbt 37,942 project of Transforming Data with dbt, beside the models they measure. Each name settles one of the arguments of Why Dashboards Disagree: booked_sales includes cancelled lines, gross_sales excludes them, and the dimension tables expose region and genre_group through the customer and book entities:

models/marts/_marts.yml (excerpt): the fact table's semantic definitionsYAML
  - name: fct_sales
    semantic_model: {enabled: true}
    agg_time_dimension: order_ts
...
    metrics:
      - name: gross_sales
        type: simple
        agg: sum
        expr: gross_amount
        filter: "{{ Dimension('sale__status') }} <> 'cancelled'"
...
      - {name: average_order_value, type: ratio, numerator: gross_sales, denominator: orders}

dim_date doubles as MetricFlow's time spine. mf validate-configs checked the definitions against the warehouse (ERRORS: 0), and one command now answers any combination of metrics and dimensions:

Querying the shared metrics with MetricFlow
mf query --metrics booked_sales,gross_sales,orders,average_order_value \
  --group-by metric_time__quarter --order metric_time__quarter
Output
metric_time__quarter      booked_sales    gross_sales    orders    average_order_value
----------------------  --------------  -------------  --------  ---------------------
2025-01-01T00:00:00             583738         549250     15496                35.4446
...
2026-04-01T00:00:00             571022         536145     15586                34.3992

Grouping gross_sales by customer__region and book__genre_group for 2026's second quarter returned exactly the figures of BookNest's Star Schema (Americas Fiction & Lit 92,965), and --explain showed the generated SQL joining fct_sales to dim_customer with the status filter applied once. Grouped ratios need care: average order value per genre group divides that group's sales by the orders containing it, so it does not average to the total.