Define a saved query in dbt MetricFlow YAML to standardize a commonly used metric + dimension combination for BI tool consumption

domain: docs.getdbt.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Add a saved_queries block in a YAML file within your dbt project, providing a name and label for the saved query
  2. Under the metrics key, list one or more metric names that should be returned together
  3. Under group_by, list the dimension names using the entity__dimension format (e.g., order__order_date) to specify the slicing grain
  4. Optionally add a where clause filter using Jinja-style syntax to pre-scope the query (e.g., filter by a specific channel)
  5. Test execution with dbt sl query --saved-query YOUR_SAVED_QUERY_NAME and verify the output matches expected values before committing

Known gotchas

Related routes

Configure a MetricFlow time spine in YAML (dbt v1.9+ format) to support time-series metric queries
docs.getdbt.com · 5 steps · unrated
Define a MetricFlow semantic model in YAML with primary, foreign, and unique entity types to enable automatic join resolution
docs.getdbt.com · 5 steps · unrated
Query the dbt Cloud Semantic Layer GraphQL API to retrieve metric values with dimension breakdowns
docs.getdbt.com · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans