What is TMDL in Power BI?

Cody Schneider8 min read

Tabular Model Scripting Language, or TMSL, is the instruction set that tells Power BI how to build, manage, and modify your data models. While you might not write it by hand every day, understanding what it is and what it does is a powerful step in taking your Power BI skills from intermediate to advanced. This article will break down what TMSL is, why it matters, and how you can start using it to automate tasks and manage your models more effectively.

GraphedGraphed

Your AI Data Analyst to Create Live Dashboards

Connect your data sources and let AI build beautiful, real-time dashboards for you in seconds.

Watch Graphed demo video

What is TMSL, Really? (Beyond the Acronym)

Think of your Power BI report as a finished house. The visual charts and graphs are the paint, furniture, and decorations. The DAX (Data Analysis Expressions) formulas are the electrical wiring and plumbing - the functional logic that makes everything work inside the house. So where does TMSL fit in? TMSL is the architectural blueprint for the house itself. It's a structured script, written in a format called JSON (JavaScript Object Notation), that defines the entire foundation and structure of your Power BI Semantic Model (what used to be called a "dataset").

The "Language" of Your Data Model

When you use the Power BI Desktop interface to create a relationship, rename a column, or import a new table, Power BI is generating and executing TMSL commands behind the scenes. The script contains definitions for everything in your model, including:

  • Tables, columns, and their data types
  • Relationships between tables
  • Calculated measures and columns
  • Data refresh settings and partitions
  • Perspectives and role-based security rules

Because it's just a text-based script, you can save it, edit it, share it, and use it outside of the Power BI interface. This is where its real power lies.

Where Does DAX Fit In?

It's easy to get TMSL and DAX confused, but they have very different jobs. Understanding the difference is fundamental to mastering Power BI's architecture:

  • DAX is the language of calculation and queries. You use DAX to ask questions about your data inside the model. Formulas like SUM(), CALCULATE(), and AVERAGE() are all DAX. It's for analysis.
  • TMSL is the language of definition and management. You use TMSL to define the structure of the model itself. Commands like "create this table," "alter this relationship," or "refresh this partition" are TMSL. It's for administration and architecture.

In short: You use TMSL to build the building, and you use DAX to ask what's happening inside it.

Why Should You Bother Learning TMSL?

You can build fantastic reports without ever looking at a line of TMSL code. However, as your projects grow larger and more complex, relying solely on the point-and-click interface can become a bottleneck. Knowing how to leverage TMSL unlocks a new level of efficiency and control.

Free PDF Guide

AI for Data Analysis Crash Course

Learn how to get AI to do data analysis for you — the best tools, prompts, and workflows to go from raw data to insights without writing a single line of code.

Automating Repetitive Tasks

Imagine you have a huge dataset covering years of sales data. A full data refresh takes over an hour. But you only need to update the last 30 days of data. With TMSL, you can write a short script to command a partial refresh on only the relevant partition (e.g., just the current month's table). This is dramatically faster and reduces the load on your data sources and the Power BI service.

Source Control and Versioning for Your Data Model

Have you ever been terrified of making a change to a mission-critical Power BI model, worried you might break something and not know how to get back? Since your model's entire structure can be exported as a single TMSL script, you can save it to a version control system like Git. This allows you to:

  • Track every change made to the model over time.
  • Clearly see the differences between version 1.0 and version 1.1.
  • Revert to a previous, stable version if a new change causes problems.
  • Allow multiple developers to work on the model's structure without stepping on each other's toes.

Making Bulk Changes Effortlessly

Let's say a business requirement changes, and you need to add the same description or change the display folder for 50 different measures. Clicking through each one in Power BI Desktop would be tedious and error-prone. With TMSL, you can script the entire model, use a find-and-replace function in a text editor to make the changes in seconds, and execute the modified script to update the model. It turns a 30-minute chore into a 30-second fix.

Advanced Deployment Scenarios (CI/CD)

For enterprise-level Power BI development, TMSL is non-negotiable. It allows BI professionals to create a CI/CD (Continuous Integration/Continuous Deployment) pipeline. This means you can have separate Development, Test, and Production workspaces. You can programmatically deploy model changes from one environment to the next, test them automatically, and ensure that only proven, stable versions make it to your end users. This is professional-grade BI management, and it's all powered by TMSL.

Getting Started with TMSL: A Practical Walkthrough

The best way to get a feel for TMSL is to see it in action. You won't be using Power BI Desktop for this, instead, you'll use a popular free third-party tool that's become essential for serious Power BI developers.

GraphedGraphed

Your AI Data Analyst to Create Live Dashboards

Connect your data sources and let AI build beautiful, real-time dashboards for you in seconds.

Watch Graphed demo video

Your Primary Tool: Tabular Editor

Tabular Editor is a lightweight application that allows you to connect directly to the data model running behind your Power BI Desktop file or in the Power BI Service. It gives you a more direct, developer-focused view of your model's structure and is the perfect place to interact with TMSL. You can download and install Tabular Editor 2 (the free, open-source version) to follow along.

Once installed, you can launch it from the "External Tools" ribbon in Power BI Desktop.

Viewing the TMSL for a Single Table

Let's see the blueprint for one part of 'the house'.

  1. Open a Power BI report with a few tables loaded into the model.
  2. Go to the "External Tools" tab in Power BI Desktop and click "Tabular Editor."
  3. Tabular Editor will open, showing a tree view of your model's tables, columns, and relationships on the left-hand side.
  4. Right-click on any table (e.g., your 'Sales' table) and select Script Table.

A new window will appear showing you the TMSL script and an auto-generated set of instructions used to 'build' that table in your model. It will look something like this:

| { | "createOrReplace": { | "object": { | "database": "...", | "table": "Sales" | }, | "table": { | "name": "Sales", | "columns": [ | { | "name": "OrderID", | "dataType": "int64", | "sourceColumn": "OrderID", | "formatString": "0" | }, | { | "name": "SaleDate", | "dataType": "dateTime", | "sourceColumn": "SaleDate" | }, | { | "name": "Revenue", | "dataType": "decimal", | "sourceColumn": "Revenue", | "formatString": "\$#,0.00,(\$#,0.00),\$#,0.00" | } | ], | "partitions": [ | { | "name": "Partition", | "source": { | "type": "m", | "expression": [ | "let", | " Source = Csv.Document(File.Contents("C:\Data\Sales.csv"), ...),", | ... | ] | } | } | ] | } | } | }

Even if you don't understand every line, you can clearly see the structure. It's defining a table named "Sales" with columns like "OrderID" and "Revenue" and telling Power BI where to get the data from via a Power Query (M) expression.

Free PDF Guide

AI for Data Analysis Crash Course

Learn how to get AI to do data analysis for you — the best tools, prompts, and workflows to go from raw data to insights without writing a single line of code.

Common TMSL Commands to Know

Most TMSL scripts revolve around a few core commands within the JSON structure:

  • create: Used to add a new object, like a table or a relationship, that doesn't currently exist.
  • alter: Used to modify the properties of an existing object, such as renaming a column.
  • delete: Used to remove an object from the model entirely.
  • refresh: Used to instruct the model to update the data in a table or partition.
  • createOrReplace: A convenient command that creates an object if it doesn't already exist or completely overwrites any pre-existing version of that element.

You rarely write these complex scripts from scratch. Instead, developer tools and automated processes create these types of programmatic instructions that define how to maintain your Power BI data model(s).

Is This Overkill For Me?

After seeing the code and hearing about CI/CD pipelines, you might be wondering if this is a step too far. For many marketers, business owners, and analysts, the answer is yes. You are not the person this was built to serve – this functionality was actually developed to empower Power BI to compete with enterprise BI solutions that offer organizations complete, end-to-end control of their analytics practice.

However, simply knowing that TMSL exists is valuable, because it changes your perception of what a Power BI model is. It isn’t just a magic black box, it's a structured database whose architecture can be saved, scripted, and manipulated programmatically.

The next time you're stuck clicking through the same repetitive update over and over, you'll know there's a more powerful way. Your problem is searchable - you can now look for solutions involving "automating Power BI" or "scripting model changes," because you know the underlying language exists to make it happen.

Final Thoughts

TMSL is the structural language that defines your Power BI models, working behind the scenes to build tables, set relationships, and manage data refreshes. While DAX is for analysis, TMSL is for architecture and administration. Learning to leverage it with tools like Tabular Editor can save countless hours by automating repetitive jobs, enabling version control, and streamlining deployments for complex projects.

The scripting complexity and steep learning curve associated with tools like Power BI are precisely the frustrations we built Graphed to solve. Rather than mastering TMSL to automate a data refresh or digging through menus to build a dashboard, we provide a simpler path. You can connect your marketing and sales data sources in seconds and use simple, conversational language to build real-time reports and dashboards, freeing you up to focus on insights instead of infrastructure.

Related Articles