Save Power BI reports to TMDL with pbip

Posted by:

|

On:

|

The new Tabular Model Definition Language (TMDL for short) has been around for almost a year now. TMDL is meant to simplify collaboration and facilitate the reading by human beings of tabular models.

With the February 2024 Fabric update, TMDL can now be set up to be the new default format when saving tabular models as pbip. Pbip already played a big role in simplifying the merging of changes and collaborative Power BI developement. But with TMDL, things take even a step further.

For a refresher on what pbip is, go check my other blog post: Power BI CI/CD & git integration.

Let’s dig in !

What is TMDL?

As we said in the introduction, TMDL stands for Tabular Model Definition Language. To understand what new features TMDL brings, we first need to understand what TMDL replaces. TMDL replaces a language called TMSL. TMSL stands for Tabular Model Scripting Language and it’s been around for almost a decade now.

TMDL’s ancestor: TMSL

TMSL is a language used to define tabular models structure. It is also used communicate programatically with them. Tabular models are a special kind of databases that compress very well the data and read data from your memory instead of your disk which makes them very fast. Tabular models are at the source of every Power BI report. In them are defined and stored tables, columns, relationships, measures: basically everything apart from visualisations.

TMSL stores most of this tabular model metadata in a file called model.bim. Even before the pbip format was released, some external tools like Tabular Editor could connect to the model.bim file of your pbix file and let you edit it directly. With the pbip format, it’s even simpler now to see for yourself that model.bim file. Just save your report as a pbip file and go check that model.bim file.

TMSL also comes with a different set of commands that can interact with tabular models. One very well known TMSL command is the refresh command. It’s used to refresh a tabular model and can be used to trigger the refresh of a Power BI semantic model for instance.

But TMSL has many issues. First of all, as you can see in the file above, it’s pretty hard to read. The file is formatted in JSON which means it holds quite a lot a characters necessary for the structure of the file. Second, DAX and M are not natively understood by that model.bim file: you cannot just copy and paste DAX measures or M queries in Power BI. Finally, model.bim is one single large file which contains everything. So it makes harder to collaborate on that file because everyone is going to be updating it. That model.bim file also has the bad habbit of rearranging lines of code by itself, which often leads to unwanted changes.

TMDL comes in the place

TMDL tries and solve these issues. TMDL is based on YAML-like format which is easier to read. Most importantly, TMDL splits the content of the model.bim file in a multitude a small files, which makes merge and collaboration much easier.

 TMDL also understands natively DAX and M. Which means you can just copy and paste your measures here for edition and it’ll just work! For more detail on the structure of the TMDL files, you can check the Microsoft documentation: Tabular Model Definition Language (TMDL) and the awesome The Future of Version Control for Tabular Models.

Ok, so TMDL ‘s cool. It’s easier to read and just better to work with than TMSL. So how do we use it?

How to leverage TMDL in Power BI and what to be mindful of?

Leveraging the TMDL format

First of all, as of today, TMDL is still a preview feature. To be able to save your Power BI report using TMDL, you’ll first need to activate that preview feature (the typical Files –> Options and Settings –> Options –> Preview Features). Look for Power BI Project and Store semantic model using TMDL format.

Once you’ve done so, every time you save your report using the pbip file format (and only using that format, saving as pbix won’t leverage TMDL) your report will actually be saved leveraging TMDL.

This changes the structure of the files that your Power BI report is made of like we illustrated earlier. Bye bye model.bim; welcome small table files and easy collaboration!

What’s great is that you can follow the exact same pattern I illustrated on my previous blog post Power BI CI/CD & git integration and it’ll keep on working! Fabric git integration does understand the TMDL format and will save your report in the Azure DevOps repo also leveraging that format.

Limitations

One or two things need to be taken into account when using the TMDL format.

First of all, TMDL is a preview feature build on top of the pbip format, which is also a preview feature. This means that structural things can still change and there are risks with putting all your production reports in pbip / TMDL (even though it should not change that much).

Secondly once you’ve deployed to the service a Power BI report saved as TMDL (through git integration in Azure DevOps), if some content gets manually published from Power BI Desktop, it will override TMDL to TMSL. This is not what you want, so the ground rule is: whenever you start leveraging the pbip file format with TMDL and making updates through a Azure DevOps git repo, only publish changes using git integration and never manually publish from Power BI Desktop.

Finally, just like for the old model.bim file, there are times when you will only have done a simple update in a table but everything will get modified in your TMDL definition files (these tables, cultures and roles files). This creates tons of unwanted changes which pollutes your repository. As of today, there’s nothing you can do about it but who knows, maybe things will get fixed by Microsoft when TMDL goes live!

Conclusion

In this blog post, we’ve seen what the TMDL format is and what cool features it brings. It might be a little bit early to move everything to pbip / TMDL just yet, but in not so long, pbip / TMDL will probably be the safest way to publish Power BI content to the service.

Thanks for reading, stay tuned!

Posted by

in