Skip to main content

Deep dive into TMDL view for Power BI Desktop (Preview)

Headshot of article author Rui Romano

We’re excited to introduce TMDL view for Power BI Desktop. This new feature lets you script, modify, and apply changes using Tabular Model Definition Language (TMDL), providing an alternative experience to semantic modeling using code, instead of a graphical user interface such as Model view. Future updates will integrate Copilot, laying the foundation for advanced Copilot modeling interactions handling time-intensive tasks such as model translations, bulk operations, among others.

TMDL view enhances the semantic modeling experience for Power BI developers, offering several advantages:

  • Enhanced development efficiency with a rich code editor that includes search-and-replace, keyboard shortcuts, multi-line edits and more.
  • Increase reusability by easily scripting, sharing, and reusing TMDL scripts among semantic model developers.
  • Gain more control and transparency, showing all semantic model objects and properties, and allowing changes to items not available in the Power BI Desktop user interface.

Watch the TMDL view demo in the January 2025 update video (minute 5:26):

Get started

Get started today by turning on this public preview feature, go to File > Options and settings > Options > Preview features and check the box next to TMDL View.

Once the preview feature is enabled, the TMDL view tab will appear on the left side of the Power BI Desktop window:

When first opening TMDL view, the code editor will be empty, you can script any semantic model object such as table, measure or column by selecting the objects from the Data pane and dragging them into the code editor:

TMDL view scripts the selected semantic model objects into a code tab as a TMDL createOrReplace script. It’s a scripting experience similar to scripting a table or database in SQL Server Management Studio.

Each time you script an object; a new tab is created. You can have multiple script tabs at once, which can be renamed or removed.

The contents of the TMDL view tabs are saved in the file (PBIX or PBIP), so you can continue where you left off the next time you open the Power BI Desktop report.

Explore semantic model metadata

Using TMDL view to view and comprehend the semantic model metadata can be highly beneficial, even if modifications are not intended. For example, it may be necessary to review and reuse a specific Power Query expression from a table in another file or verify that all measures have the correct format string configuration.

You can script one or more objects by holding the CTRL key and either dragging the object from the Data pane into the code editor, or right-clicking and selecting the Script TMDL option to a new tab or clipboard. The full definition of the selected objects will be scripted into the code editor.

Enhance your development efficiency

Once you’ve scripted a semantic model object or pasted TMDL script into the code editor, you can use the comprehensive code experience features offered by the TMDL view code editor such as semantic highlighting, expand/collapse, error diagnostics and autocomplete.

As a code editor, TMDL view facilitates bulk changes to your semantic model efficiently and provides useful features like search-and-replace, keyboard shortcuts, and multi-line editing. For instance, if you need to remove the prefix “dim_” or “fact_” from all your tables, you can script the full model, search for “dim_|fact_” (as a regular expression), and replace it with an empty string.

When you’re ready, you can select the Apply button to execute the TMDL script against the semantic model and have your TMDL code changes applied in a single step.

When successful, a notification is displayed, and your modeling change are applied to the semantic model.

In the event of a failure, an error notification is displayed to show that your modeling changes weren’t applied to the semantic model. You can view more information about the error by selecting the Show details link in the notification, which then expands the Output pane and displays error details.

TMDL view modifies only the semantic model metadata, without refreshing data or affecting the report. If your changes require a data refresh, such as altering a PowerQuery expression or calculated column expression, it is necessary to manually refresh the table or model for the changes to take effect. Additionally, renaming a field in the TMDL view may break visuals within the report that use that field.

Change any semantic model property/object

Our great Power BI community developed rich external tools which are great helpers to authoring semantic models. With TMDL view, some features, such as perspectives and translations, that previously could only be modified or created in the external tools, can now be modified or created in Power BI Desktop. Now Power BI Desktop can author any property or feature in semantic models with TDML view, and as always, offers a quick way to access any external tool you have installed from the community, allowing you full flexibility to work interchangeably.

Easily share and reuse TMDL scripts

TMDL view introduces a new capability that allows users to share and reuse semantic model objects easily within Power BI Desktop.

For example, if you want to share a calculation group you created with a colleague, you just need to follow these steps:

  • Script the calculation group into TMDL view.
  • Copy the text and share it with your colleague via Teams chat or email.
  • Your colleague can then paste the script into a new TMDL view tab and run it to get exactly the same calculation group created on his semantic model.

Alternatively, you may centralize a collection of TMDL scripts on a SharePoint site. This will make them easily accessible for any Power BI developer within your organization, enabling them to efficiently reuse these scripts in their semantic models .

TMDL view is also excellent for community and social media sharing. For instance, if it had been available when Zoe Douglas wrote her amazing blog post about calculation groups, she could have included a TMDL script like the following to help readers create the same calculation group.

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

TMDL view vs Power BI Project

When using the TMDL Visual Studio Code extension with Power BI project files (PBIP), you can directly modify the semantic model definition and need to restart Power BI Desktop to apply changes. TMDL view goes a step further and enables scripting any object as TMDL, making modifications with a code editor, and applying these changes immediately to the model as needed, regardless of whether the file format is PBIX or PBIP, without requiring a restart

You can and should use both experiences together. For example, PBIP and Visual Studio Code can be used to update the semantic model definition without launching Power BI Desktop. The TMDL view in Power BI Desktop can be used to easily apply multiple changes to the semantic model efficiently. Both experiences with the same rich TMDL code experience.

What’s next?

As TMDL view continues its journey towards General Availability, exciting developments are on the horizon:

  • A Preview option that provides a diff view that compares the changes produced by your script versus the current version of the semantic model.
  • Extend support for non-supported modeling changes, including partitions and data sources, which will enable opening and editing any semantic model running in Fabric.
  • TMDL view on the web from published semantic models in the workspace.
  • TMDL view Copilot, an inline code assistant that converts natural language into TMDL scripts, helping semantic model developers automate time-consuming tasks comparative to GitHub Copilot.

Feedback

We highly value your input and encourage you to share it through our feedback form or the Power BI Community.

Learn more about TMDL view features and its limitations in our documentation: Work with TMDL view in Power BI Desktop (preview).