How to Use Variables in dbt

Last updated July 25, 2026 · By the SaturnSQL team

Define vars in dbt_project.yml and read them with {{ var('name') }}; pass a second argument as a default for when the var is unset. Override values at runtime with the --vars flag, which takes a YAML/JSON dict string.

Project defaults

# dbt_project.yml
vars:
  start_date: '2024-01-01'
  excluded_statuses: ['test', 'internal']

In a model

SELECT *
FROM {{ ref('stg_orders') }}
WHERE created_at >= '{{ var("start_date", "2020-01-01") }}'

Override at runtime

dbt run --vars '{"start_date": "2026-01-01"}'

Run this in SaturnSQL

SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.

Try it free

Related dbt guides

© 2026 Panda Capital Oy Ab. All rights reserved.