Skip to main content
← All posts

TMDL view in Power BI Desktop: your semantic model as a script

The January 2025 Power BI Desktop update adds TMDL view in public preview. What it does, how it fits with PBIP and Git, and where it pays off first.

Brian Bønk5 min read

Power BI Desktop now has a code view for the semantic model. The January 2025 update adds TMDL view in public preview, a new view where you script, modify and apply changes to the model using Tabular Model Definition Language (TMDL), instead of clicking through Model view.

That is a bigger deal than it sounds. Until now, anything the Desktop interface did not expose meant reaching for an external tool, or editing project files and restarting Desktop. TMDL view puts the full model metadata inside Desktop itself, with an Apply button.

What TMDL view does

You turn it on under File > Options and settings > Options > Preview features, by ticking TMDL View. A new TMDL view tab then appears on the left side of the window.

The editor starts empty. You drag objects from the Data pane into it, or right-click and choose Script TMDL to a new tab or to the clipboard. Hold CTRL to pick several objects at once. Desktop writes out the full definition as a createOrReplace script, much like scripting a table in SQL Server Management Studio.

The editor gives you what you expect from a modern code editor:

  • Semantic highlighting and expand/collapse
  • Error diagnostics and autocomplete
  • Search-and-replace (with regular expressions), keyboard shortcuts and multi-line editing

When you are happy, Apply runs the script against the open model. A notification confirms success. If it fails, nothing is applied, and Show details opens the Output pane with the error.

You can keep several script tabs open, rename them, and they are saved with the file (PBIX or PBIP), so they are still there next time you open the report.

A small example

The Microsoft deep dive post uses a time intelligence calculation group as the example of a script you can share. Paste it into a new tab, apply it, and the calculation group exists in your model:

createOrReplace

    table 'Time Intelligence'

        calculationGroup
            precedence: 1

            calculationItem YTD = CALCULATE ( SELECTEDMEASURE (), DATESYTD ( 'Calendar'[Date] ) )

            calculationItem QTD = CALCULATE ( SELECTEDMEASURE (), DATESQTD ( 'Calendar'[Date] ) )

            calculationItem MTD = CALCULATE ( SELECTEDMEASURE (), DATESMTD ( 'Calendar'[Date] ) )

            calculationItem Current = SELECTEDMEASURE()

        column 'Show as'
            dataType: string
            sourceColumn: Name
            sortByColumn: Ordinal

        column Ordinal
            dataType: int64
            formatString: 0
            summarizeBy: none
            sourceColumn: Ordinal

It assumes a 'Calendar' table with a [Date] column. Indentation is the structure in TMDL, so keep it intact when you copy scripts around.

How it fits with PBIP and Git

If you already save as a Power BI Project (PBIP) with the TMDL format, you have the model as text files in a folder: one file per table, plus files for relationships, expressions and the model itself. That is what makes Git diffs and code review readable.

The two approaches solve different problems. Editing the TMDL files in a PBIP with Visual Studio Code changes the stored definition, but you have to restart Power BI Desktop to pick up the change. TMDL view works on the model that is open right now, applies immediately, and works whether the file is PBIX or PBIP.

Microsoft's own advice is to use both. Use PBIP and VS Code for changes you want to make without opening Desktop, and TMDL view when Desktop is already open and you want to push a series of changes in one go. For teams on Git, the result of a TMDL view change still ends up as a normal diff in the PBIP files when you save.

One thing to keep in mind: TMDL view only changes metadata. It does not refresh data or touch the report. If you change a Power Query expression or a calculated column, you refresh the table yourself. And if you rename a field in a script, visuals that use it can break.

Where it pays off first

After two decades in data, the features I value most are the ones that remove small, repeated friction. A few practical uses stand out:

  1. Bulk renames. Script the whole model, use a regular expression to strip prefixes like dim_ and fact_, and apply. That replaces a long afternoon of clicking.
  2. Properties the interface hides. Things like IsAvailableInMDX, detail rows definitions, display folders across many measures, perspectives and translations can now be set in Desktop without an external tool.
  3. Reusable snippets. A calendar table or a calculation group becomes a text file. Microsoft suggests a shared SharePoint location where developers pick up standard objects.
  4. Reviewing a model. Even without changing anything, scripting the measures is a quick way to check that every format string is set as it should be.

What to do next

It is a preview, so treat it like one:

  1. Enable the preview feature in Desktop and try it on a copy of a model, not the production file.
  2. Script a single table and read it. Getting used to how TMDL represents your model is half the value.
  3. Pick one real chore, such as fixing display folders or format strings, and do it with a script.
  4. If your team uses PBIP and Git, agree where shared scripts live and how they get reviewed.

Microsoft has also listed what is coming before general availability: a preview option that shows a diff of what your script will change, support for more modeling changes such as partitions and data sources, TMDL view on the web, and a Copilot assistant inside the view. None of that is here yet, so plan around what ships today.

Takeaway

TMDL view closes a long-standing gap: the full semantic model is now visible and editable as code inside Power BI Desktop, with changes applied straight to the open model. Combined with PBIP and Git, it gives model developers a workflow that looks a lot like the rest of software development.

Which repetitive modeling task would you script first?

Sources

Enjoyed this? Get the next one by email

Occasional emails about Microsoft Fabric, SQL Server, Power BI and Synapse.

By subscribing you get occasional emails about Microsoft Fabric, SQL Server, Power BI and Synapse from ProBI. You confirm your address by email first, and you can unsubscribe at any time. Read our privacy policy.