# Dynamically disable models without breaking refs

**URL:** <https://discourse.getdbt.com/t/dynamically-disable-models-without-breaking-refs/12714>\
**Category:** Help\
**Tags:** jinja, dbt-core\
**Created:** [April 2, 2024, 6:52pm UTC](https://discourse.getdbt.com/t/dynamically-disable-models-without-breaking-refs/12714 "2024-04-02T18:52:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinr](https://sea2.discourse-cdn.com/flex020/user_avatar/discourse.getdbt.com/kevinr/32/2516_2.png) [@kevinr](https://discourse.getdbt.com/u/kevinr)\
**Post date:** [April 2, 2024, 6:52pm UTC](https://discourse.getdbt.com/t/dynamically-disable-models-without-breaking-refs/12714/1 "2024-04-02T18:52:08Z")

</div>

## The problem I’m having

I have 4 models: a, b, c, d

Models a, b, and c create views and model d unions them all at the end

What I would like to do is use a variable array i.e.

```auto
vars:
  var_array: ['a', 'b', 'c']

```

i have each model a, b, and c starting with `{% if 'a' in var('var_array') %}`

when i use the command `dbt compile --vars '{"var_array": "['a, 'c']"}'` this compiles completely fine, however if i use the command `dbt run --vars '{"var_array": "['a, 'c']"}'` model b ends up being included in the `target/run` dir as an empty query that throws an error

this is what is shown in `target/run` for model b:

```auto
  create view "postgres"."public"."b__dbt_tmp"
    
    
  as (
    
  );

```

with the corresponding error:

```auto
18:37:56 Database Error in model b (models/b.sql)
  syntax error at or near ")"
  LINE 8: );
            ^

```

Is there a way to have model b not included in the run depending on what variables are passed through?

Note: I did try to use the if statements to disable the model via the config, but I am using `dbt_utils.union_relations` in model d to union the outputs of models a, b, and c
