Skip to main content

Using MetricFlow with dbt metrics

Metricflow now integrates with dbt metrics! Metricflow will parse your dbt project, and translate the result into a Metricflow model. You can then query your metrics in any supported Metricflow interface.

Setting up the integration with MetricFlow

  1. Configure metrics in your dbt project. For example, we have the metric salesforce_opportunties.
- name: salesforce_opportunities
label: Opportunities
model: ref('opportunity_base')
description: "Count of opportunities"
calculation_method: count_distinct
expression: id
timestamp: created_date
time_grains: [day, week, month]
- stage_name
meta: {team: Sales}
  1. To install metricflow for use with dbt you do the following pip install "metricflow[your-dbt-adaptor]" , replacing the your-dbt-adaptor variable with whatever supported data warehouse you use (currently dbt-snowflake, dbt-redshift, dbt-postgres , and dbt-bigquery)

  2. In your .metricflow/confg.yml, the key model_path should point to your dbt project directory. Add the additonal key dbt_repo: "true"

After this is done, all other MetricFlow commands, $ mf command options, should work as normal but now from your dbt metrics! 🎉

For example, you can query the salesforce_opportunities metric with the following command

mf query --metrics salesforce_opportunities --dimensions metric_time