MetricSign
EN|NLRequest Access
High severitydbt

Power BI Refresh Error:
Compilation Error: Invalid ref function

What does this error mean?

A ref() call in a dbt model references a model that does not exist in the project. The model name is misspelled, was renamed, or belongs to a package that is not installed.

Common causes

  • 1The model name in the ref() call is misspelled or does not match the .sql filename exactly
  • 2The referenced model was renamed or deleted
  • 3The model belongs to a dbt package listed in packages.yml that has not been installed via `dbt deps`

How to fix it

  1. 1Check the spelling of the model name in the ref() call — it must exactly match the .sql filename without the extension.
  2. 2Run `dbt ls` to see all models that dbt can resolve.
  3. 3If the model is in a package, ensure the package is listed in packages.yml and run `dbt deps`.
  4. 4Check for circular dependencies using the lineage graph in dbt Cloud.

Frequently asked questions

What is the difference between ref() and source() in dbt?

ref() references dbt models in your project (they compile to schema.table). source() references raw tables from sources.yml that exist outside your models. Using ref() for a source table causes a compilation error.

Can a typo in a model name cause this error?

Yes — ref('my_model_naem') with a typo will fail at compilation because dbt cannot find a model with that exact name. dbt model names are case-sensitive in some databases; confirm the model name matches exactly.

Does renaming a dbt model break downstream models?

Yes — renaming a model without updating every ref() that uses the old name breaks all downstream models at compilation. Search all SQL files for the old name before renaming.

Official documentation: https://docs.getdbt.com/guides/debug-errors

Other dbt errors