# dbt variable defined in dbt\_project.yml can't be used in same dbt\_project.yml file

**URL:** <https://discourse.getdbt.com/t/dbt-variable-defined-in-dbt-project-yml-cant-be-used-in-same-dbt-project-yml-file/6752>\
**Category:** Help\
**Tags:** variables, devblog, dbt-core\
**Created:** [February 10, 2023, 10:06am UTC](https://discourse.getdbt.com/t/dbt-variable-defined-in-dbt-project-yml-cant-be-used-in-same-dbt-project-yml-file/6752 "2023-02-10T10:06:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhajpasha](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/minhajpasha/32/1159_2.png) [@minhajpasha](https://discourse.getdbt.com/u/minhajpasha)\
**Post date:** [February 10, 2023, 10:06am UTC](https://discourse.getdbt.com/t/dbt-variable-defined-in-dbt-project-yml-cant-be-used-in-same-dbt-project-yml-file/6752/1 "2023-02-10T10:06:16Z")

</div>

Hello  
@joellabes

Iam Unable to used the variable defined in dbt\_project.yml in the same file.

I have defined the variable in dbt\_project.yml file as below

vars:  
gcp\_project\_id: ‘gcp-dev-sandbox’  
local\_time\_zone: ‘Europe/London’  
dag\_id: “customers\_load”

I want to use the the variable dag\_id to create target folder as below

target-path: “target/{{ var(‘dag\_id’) }}”

When i run it as below it fail’s

→ dbt run --select tag:customers\_load

File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/utils.py”, line 196, in \_deep\_map\_render  
ret = func(value, keypath)  
File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/config/renderer.py”, line 143, in render\_entry  
result = super().render\_entry(value, keypath)  
File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/config/renderer.py”, line 33, in render\_entry  
return self.render\_value(value, keypath)  
File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/config/renderer.py”, line 45, in render\_value  
raise CompilationException(msg) from exc  
dbt.exceptions.CompilationException: Compilation Error  
Could not render target/{{ var(‘dag\_id’) }}: Required var ‘dag\_id’ not found in config:  
Vars supplied to = {}  
09:46:53 Encountered an error:  
Compilation Error  
Could not render target/{{ var(‘dag\_id’) }}: Required var ‘dag\_id’ not found in config:  
Vars supplied to = {}

Alternatively  
i need to run it to pass the variable in dbt run , this make life complex as we need to pass var for each run if we are doing to test locally.

→ dbt run --select tag:customers\_load --vars {“dag\_id”: “customers\_load”}
