Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

FataiSanni

TMDL View in Power BI: The Game-Changer for Semantic Model Management

 

If you've ever struggled with bulk-editing Power BI models, wished you could version control your semantic models properly, or wanted to share reusable model components with your team, you're in for a treat. The Tabular Model Definition Language (TMDL) view in Power BI Desktop is transforming how developers work with semantic models, and it might just become your new favorite feature.

In this post, I'll walk you through the practical benefits of TMDL view with real-world examples that demonstrate why this feature deserves a spot in every Power BI developer's toolkit.

 

FataiSanni_3-1760995772319.png

 

What Is TMDL View?

TMDL view provides a modern code editor within Power BI Desktop that lets you script, modify, and apply changes to semantic model objects using Tabular Model Definition Language. Think of it as unlocking a developer-friendly interface to your entire data model, complete with search-and-replace, IntelliSense, keyboard shortcuts, and multi-line editing capabilities.

Unlike the legacy Tabular Model Scripting Language (TMSL) which uses one large JSON file, TMDL uses a YAML-like syntax that's human-readable and optimized for collaboration.

Three Major Benefits You Need to Know

  1. Enhanced Development Efficiency

Let's say you have a Power BI model with multiple tables prefixed with dim_ and fact_ (common in data warehouse naming conventions), but you want to clean up those prefixes for a cleaner user experience. Traditionally, you'd need to:

  • Double-click each table individually to rename it
  • Navigate through the Power Query Editor for each table
  • Manually update all relationships and measures that reference those tables

With TMDL view, you can accomplish this in seconds:

  1. Navigate to Model view and select TMDL view
  2. Script your semantic model by dragging it into the editor
  3. Use Ctrl + H (Find and Replace) to replace dimproduct and dim_product across all tables at once
  4. Preview your changes before applying them
  5. Click Apply to update your model

 

Pro tip: Before making bulk changes, create a backup by scripting your current model to a new tab. If something breaks, you can quickly revert by applying the backup script.

The TMDL view code editor includes semantic highlighting, autocomplete with Ctrl+Space, context tooltips on hover, and built-in error diagnostics that help identify and fix issues with detailed guidance.

  1. Increased Reusability

Here's a common scenario: you've built a perfect Calendar Date table with proper sort orders, date hierarchies, and properties configured exactly right. Now you want to use it in another report.

With traditional methods, copying the table brings only the data structure, you lose all the metadata like sort-by columns, format strings, and other properties.

With TMDL view, you can:

  1. Script your Calendar table (or any model object) to TMDL
  2. Copy the entire TMDL script
  3. Paste it into a new Power BI Desktop file's TMDL view
  4. Apply the changes

The result? You can script entire sections like measures, tables, or columns, and use TMDL scripts to easily share and reuse semantic model objects among developers, such as calendar tables or time intelligence calculation groups. All properties, including sort orders, hierarchies, and formatting, come along for the ride.

This opens up powerful possibilities for:

  • Centralized component libraries: Store reusable TMDL scripts in SharePoint or a Git repository
  • Standardization: Ensure consistent naming conventions and configurations across projects
  • Faster development: Build once, reuse everywhere
  1. Complete Control and Transparency

TMDL view exposes model elements that aren't available through the standard Power BI Desktop interface. Want to create perspectives to provide filtered views of your model? Before TMDL view, you needed third-party tools like Tabular Editor.

Now you can create perspectives directly in Power BI Desktop:

create perspective MeasureSalesView
  perspectiveTable 'fact_Sales'
    perspectiveMeasure 'Total Revenue'
    perspectiveMeasure 'Total Qty Sold'

After applying this script, your perspective appears in the model and can be tested in the Power BI Service.

TMDL view shows all semantic model objects and properties, allowing changes to items not available in the Power BI Desktop user interface, such as perspectives.

 

The DirectQuery "Reversibility" Trick

Here's something that will blow your mind: we all know that switching from DirectQuery mode to Import mode is possible, but switching back to DirectQuery is not supported because of feature set differences.

But with TMDL view, you can work around this limitation:

  1. Script your model to TMDL view
  2. Use Ctrl + F to find instances of mode: import
  3. Replace with mode: directQuery
  4. Preview and apply the changes

FataiSanni_1-1760995600851.png

 

Important caveat: While this technically works for changing the storage mode property in the model metadata, this is a workaround and should be used with caution. Microsoft's official guidance states that switching from Import back to DirectQuery is not supported due to feature compatibility issues. Test thoroughly in a development environment before attempting this in production scenarios.

How to Access TMDL View

TMDL view is available in Power BI Desktop. To use it:

  1. Navigate to Model view in Power BI Desktop
  2. Look for the TMDL view option in the ribbon
  3. Drag any object from the Data pane into the code editor to script it
  4. Or right-click an object and select Script TMDL to new tab

You can script any semantic model object such as a table, measure, or column by selecting objects from the Data pane and dragging them onto the code editor.

For an even better editing experience when working with TMDL files outside of Power BI Desktop, Visual Studio Code with the TMDL Language extension provides syntax highlighting and enhanced editing capabilities.

Best Practices and Tips

Always create backups: Before making bulk changes via TMDL, script your current model to a separate tab. This gives you an instant rollback option if something goes wrong.

Use Preview before Apply: The Preview feature shows you exactly what will change, with red (removed) and green (added) highlighting. Review these carefully before committing changes.

Leverage IntelliSense: Press Ctrl + Space at any point in your TMDL code to see available properties and values. This reduces syntax errors and speeds up development.

Format your code: Keep your TMDL readable by using Shift + Alt + F to auto-format your code.

Start small: If you're new to TMDL, start by scripting single objects and reviewing the syntax before attempting complex multi-object operations.

The Bigger Picture: Source Control and Collaboration

While this article focuses on the TMDL view within Power BI Desktop, it's worth noting that TMDL is the semantic model file format for Power BI Project files, which enables better source control integration and allows multiple developers to work on the same report simultaneously through traditional branching and merging processes.

With TMDL's folder structure featuring individual files for each table, perspective, role, and culture, reviewing Git diffs and resolving merge conflicts during PR processes becomes much simpler.

 

Conclusion

TMDL view in Power BI Desktop represents a significant leap forward in developer experience. Whether you're doing bulk operations, building reusable components, or accessing advanced model features, TMDL view gives you the power and flexibility that modern data development demands.

The combination of a rich code editor, complete model transparency, and the ability to version control your semantic models makes TMDL view an essential tool for serious Power BI developers.

Next Steps

Ready to dive deeper? Check out the official TMDL documentation on Microsoft Learn for comprehensive guides and examples.

For advanced scenarios, explore the Tabular Model Definition Language overview to understand the full capabilities of the TMDL language.

Check out the video that inspired this post from GuyInACube https://www.youtube.com/watch?v=WGMIoteHMs4 

 

What's your experience with TMDL view? Have you found creative ways to use it in your Power BI workflows?

Drop a comment below and share your thoughts, I'd love to hear how you're leveraging this powerful feature!

Comments