Skip to content

Using MetricFlow with Dataface

Dataface and MetricFlow are a wonderful pairing! 🚀

By combining Dataface's declarative dashboards with MetricFlow's powerful semantic layer, you can build robust, consistent analytics without writing a single line of SQL in your dashboard definitions.

This guide shows you how to take advantage of MetricFlow to make your Dataface dashboards cleaner, more maintainable, and easier to build.


Why MetricFlow + Dataface?

Traditionally, BI tools require you to write SQL queries for every chart, or model data specifically for the tool. This leads to: - Inconsistent metrics: "Revenue" might be calculated differently in two different charts. - Maintenance headaches: Changing a metric definition requires updating SQL in 20 different places. - Rigid querying: Hard to drill down or change time grains on the fly.

MetricFlow solves this by letting you define metrics once in your dbt project. Dataface then simply asks for "revenue by month," and MetricFlow generates the correct SQL.

The Benefits

  1. Single Source of Truth: Define metrics in dbt. Use them everywhere in Dataface.
  2. No SQL Required: Write clean, readable YAML instead of complex SQL queries.
  3. Automatic Flexibility: Change time grains (day, week, month) or filter by dimensions without rewriting queries.
  4. DRY Dashboards: Re-use standard metrics across different boards and layouts effortlessly.

How It Works

Using MetricFlow in Dataface is a simple, streamlined process.

1. Define Metrics in dbt

First, ensure your metrics are defined in your dbt project. This is the hard work, but you only do it once!

# dbt_project.yml or schema.yml
metrics:
  - name: total_revenue
    type: simple
    type_params:
      measure: revenue

(See the official MetricFlow documentation for details on defining metrics.)

2. Reference in Dataface

In your Dataface dashboard, you simply reference the metric by name. No SELECT, FROM, or GROUP BY needed.

# dashboard.yml
queries:
  revenue_trend:
    metrics: [total_revenue]
    dimensions: [order_date]
    time_grain: month

3. Let Dataface Handle the Rest

Dataface communicates with MetricFlow to: 1. Fetch the metric definition. 2. Construct the appropriate query for the requested dimensions and grain. 3. Execute the query and render your chart.


Power Features

Dataface exposes the full power of MetricFlow directly in your dashboard YAML.

flexible Time Grains

Want to see the same metric by week instead of month? Just change one line.

queries:
  revenue_weekly:
    metrics: [total_revenue]
    dimensions: [order_date]
    time_grain: week  # <-- Easy!

Dynamic Filtering

Pass dashboard variables directly into MetricFlow filters. Dataface handles the binding for you.

queries:
  regional_sales:
    metrics: [total_revenue]
    dimensions: [region]
    filters:
      region: "{{ inputs.selected_region }}"  # Dynamic filtering

Multi-Metric Analysis

Combine multiple metrics in a single query to see correlations.

queries:
  overview:
    metrics: [total_revenue, order_count, average_order_value]
    dimensions: [month]

Best Practices

To get the most out of this pairing:

  • Name Metrics Clearly: Use descriptive names in dbt (total_revenue_usd, active_users_7d) so dashboard creators know exactly what they are getting.
  • Use Dimensions Generously: Define common dimensions (like region, customer_segment) in dbt so they are available for grouping and filtering in Dataface.
  • Test in dbt: Use dbt sl query to verify your metrics return what you expect before building dashboards.

Learn More