Business Intelligence Data Analytics Power BI

Tabular Model Definition Language (TMDL) in Power BI: Complete Guide Including Scripting

Tabular Model Definition Language (TMDL) in Power BI: Complete Guide Including Scripting
Power BI

Tabular Model Definition Language (TMDL) in Power BI: Complete Guide Including Scripting

⏱️ 10 min read
Power BI · Business Intelligence · Updated December 2026
Tabular Model Definition Language (TMDL) guide: the Power BI semantic model format that replaces a single TMSL JSON file with one file per object, by Numlytics

A text format for Power BI semantic models, built for source control.

Tabular Model Definition Language (TMDL) is the text format Microsoft uses to describe Power BI semantic models, and it is the foundation for putting a data model under version control. This guide explains the format, the folder structure, how it supports Git and CI/CD, and how TMDL view lets you script changes in Power BI Desktop.

It merges and replaces our earlier TMDL guide and our TMDL scripting guide, and it corrects two things older articles got wrong: TMDL view in Desktop is no longer a preview feature, and TMDL and XMLA are not alternatives to each other.

What Is Tabular Model Definition Language (TMDL)?

TMDL is an object model definition syntax for tabular data models. It is fully compatible with the Tabular Object Model, so every TMDL object exposes the same properties as the underlying model. It is text-based and uses a grammar similar to YAML, with indentation to show parent and child objects, and it works well for properties that embed DAX and Power Query expressions.

It applies to semantic models in Power BI and Fabric, and to SQL Server Analysis Services and Azure Analysis Services models at compatibility level 1200 or higher. Its folder representation, with each model object in its own file, is what makes it friendly to source control.

TMDL vs TMSL: Why the Format Shift Matters

The older format, Tabular Model Scripting Language (TMSL), is JSON. In a Power BI project it is stored as one large model.bim file, so an edit to any table changes the same file. That makes diffs noisy and merge conflicts likely when two people work on the same model.

TMDL splits the model into separate files for each table, perspective, role and culture. Changes stay inside the files they touch, so diffs are smaller, merges are easier, and reviewers can see what changed. A Power BI project stores the semantic model as TMSL or TMDL, not both, and a definition.pbism file at version 4.0 or above can hold either.

The TMDL Folder Structure Explained

In a Power BI project that uses TMDL, the model sits in a definition folder instead of a model.bim file. Each table has its own file, and the model, database and relationships have theirs.

definition/
  tables/
    product.tmdl
    sales.tmdl
    calendar.tmdl
  relationships.tmdl
  model.tmdl
  database.tmdl

A new team member, an auditor or a consultant can read the model structure from the folder alone, and security roles can be reviewed as text without opening Power BI Desktop. Fabric Git integration stores a semantic model the same way, as a definition.pbism file plus a definition folder of TMDL files.

How Tabular Model Definition Language Enables Git and CI/CD

Once the model is a folder of small text files, normal software practice applies. Developers work on branches, changes show as readable diffs, pull requests give a review step, and the reviewed model is promoted through environments. Microsoft's own guidance recommends the TMDL format when you plan to use source control, when you want to change metadata efficiently, or when you work with tools such as Visual Studio Code or Tabular Editor.

Pair it with Fabric Git integration and deployment pipelines for controlled promotion. Our Power BI Governance Platform adds monitoring on top, and our Power BI consulting team can set up the branching and review model for you.

TMDL Scripting in Power BI with TMDL View

TMDL view is a code editor inside Power BI Desktop that lets you script, change and apply changes to semantic model objects. It is an alternative to the graphical Model view, not a replacement, and the two work on the same model.

Script your first object

Open TMDL view from the icon along the left side of Desktop, then drag a table, column or measure from the Data pane into the editor. Power BI scripts the whole object as a createOrReplace TMDL script, or opens a new tab if the current one is not empty. You can also right-click an object and choose Script TMDL. A script has one command verb at the top, followed by the objects.

createOrReplace

  ref table Sales
    measure '# Products (with Sales)' = DISTINCTCOUNT('Sales'[ProductKey])
        formatString: #,##0

Preview, then apply

Select Preview to see a diff of the semantic model before and after the script runs, which is useful when you paste a script from another source. Select Apply to run it. If it fails, the model is not changed and the Output pane shows the error. Applying changes only metadata: it does not refresh data, and renaming a field can break visuals that use it.

What TMDL view gives you

  • Semantic highlighting, autocomplete, tooltips, code actions such as generating lineage tags, formatting and error diagnostics.
  • Bulk edits with search and replace, including regular expressions. Microsoft's example removes a dim_ or fact_ prefix from over 100 tables in one pass.
  • Access to properties the interface does not show, such as IsAvailableInMDX and DetailRowsDefinition, and to objects such as perspectives and translations that have no graphical editor.
  • Reuse: script a calendar table or a time intelligence calculation group once and share it between models.

Renaming needs one extra step: to rename an object, script its parent, so a column rename means scripting the table. If a change needs a higher compatibility level, TMDL view prompts you to upgrade.

Desktop and web

WhereStatusHow it behaves
DesktopGenerally availableScripts are saved with the file, and in a PBIP as .tmdl files in a TMDLScripts folder
Web (service and Fabric portal)PreviewView and Edit modes, scripts are not saved, write permission needed, uses workspace version history
"TMDL is the format. TMDL view is how you script it."

TMDL vs XMLA: Language, Protocol and When to Use Each

Older guides compare TMDL with XMLA as if they were two ways of doing the same job. They are different kinds of thing. TMDL is a language and file format. XMLA is the protocol that tools use to talk to a published semantic model, and it is how TMSL scripts and the Tabular Object Model reach it.

QuestionTMDLTMSLXMLA endpoint
What it isText language and file formatJSON scripting language and file formatConnection protocol and endpoint
Where you meet itPBIP definition folder, TMDL view, Gitmodel.bim, scripts run in SSMSTools such as SSMS and ALM Toolkit connecting to a published model
ReadabilityHigh, YAML-like indentationDense at scaleNot applicable, it carries commands
Git diffs and reviewsGood: one file per objectPoor: one large fileNot applicable
Needs a capacityNo for files and DesktopNo for filesYes: Premium, Fabric or PPU, read-write enabled by an admin
Best useAuthoring, review, scripting, version controlLegacy scripts and older projectsAutomation and tools against a published model

In practice, use TMDL for authoring and version control, and the XMLA endpoint for tools and automation against published models. A mature team uses both. Note that the XMLA endpoint is read-only by default, and a capacity admin has to enable read-write before tools can change a model.

Key Takeaways
  • TMDL splits a model into one file per object, which makes Git diffs and reviews practical.
  • TMDL view in Desktop is generally available; TMDL view on the web is in preview.
  • A project stores the model as TMSL or TMDL, never both.
  • TMDL is a format and XMLA is a protocol, so they complement each other.
  • Applying a script changes metadata only; refresh data yourself if you change queries.

The Business Case for Tabular Model Definition Language

Without a text format, it is hard to see what changed in a model, who changed it and whether anyone reviewed it, and rollback is manual. With TMDL in Git, three practical gains follow: lower deployment risk because changes are reviewed, faster delivery because people can work in parallel and reuse scripts, and better model quality because peer review becomes normal.

We have not put a percentage on these gains, because they depend on your team and your starting point. A quick way to find yours is the Data Maturity Scorecard.

How to Start with Tabular Model Definition Language

  1. Save a model as a Power BI project and store the semantic model in TMDL format. Check for a definition folder instead of model.bim, and for a definition.pbism at version 4.0 or above.
  2. Open TMDL view and script one measure to get comfortable with the editor.
  3. Preview and apply a small change, such as a format string.
  4. Commit the project to a Git branch and open a pull request for the change.
  5. Build a shared library of approved scripts, such as a date table and calculation groups, before you scale up.

If you edit files in the definition folder with Visual Studio Code, save in Desktop first and use the apply external changes prompt to reload. If the prompt does not appear, reopen the project.

Limits and Gotchas

  • Setting up the first Git integration from a workspace does not include TMDL view scripts saved in the published semantic model.
  • Only one command verb per script is supported.
  • Incomplete or incorrect edits can cause unexpected behaviour, so use Preview and keep a backup script.
  • Column names are separate from sourceColumn, so a rename in TMDL does not add a rename step in Power Query.

Tabular Model Definition Language FAQ

Is TMDL view generally available?

TMDL view in Power BI Desktop is generally available. TMDL view on the web, in the Power BI service and Fabric portal, is in preview. Older articles, including earlier versions of this one, describe it as a Desktop preview feature, which is no longer accurate.

What is the difference between TMDL and TMSL?

Both describe a semantic model. TMSL is JSON, and in a Power BI project it lives in a single model.bim file. TMDL is a text format with YAML-like indentation that splits the model into a folder of files, one per table, role, perspective and culture. A project stores the model as one or the other, not both.

Do I need the TMDL file format to use TMDL view?

No. TMDL view is a scripting interface that works whether the file is a PBIX or a PBIP. The TMDL file format is what you need for a Git-friendly folder of model files. You can use either one without the other, and many teams use both.

Is TMDL the same as XMLA?

No. TMDL is a language and file format. XMLA is a protocol that client tools use to connect to a semantic model on a Premium, Fabric or Premium Per User capacity. Read-only connectivity is on by default, and read-write has to be enabled by a capacity admin.

Does applying a TMDL script refresh my data?

No. TMDL view changes only the model metadata. If you change a Power Query expression or a calculated column, you must refresh the table or model yourself. Renaming a field can also break visuals that use it.

Can I edit TMDL files outside Power BI Desktop?

Yes. In a PBIP project you can edit the files in the definition folder in Visual Studio Code or another editor, with the TMDL extension for Visual Studio Code for syntax support. Save in Desktop first, and Desktop offers to apply the external changes.

To put this into practice, see our Power BI consulting services, or talk to a certified consultant.

Moving older models? Read SSAS to Microsoft Fabric: tabular and multidimensional migration for reporting.