Skip to main content

Introduction to TMDL

Let's think of a scenario where you have asked to batch edit your long list of DAX, create repetitive measures over and over, copy whole set of measures from one PBIX to another. Until January 2025, if I encounter all those scenarios I always think of some external tools to achieve it. But but but Power BI does listen to you 😂 and now we have TMDL (Tabular Model Definition Language). In today's blog we will explore the capabilities of TMDL. 

Before we get started, TMDL is still in Preview features. You need to enable it under your settings and restart your Power BI desktop. You will see an icon for TMDL on the left pane. To learn more about TMDL do visit the detailed article from Microsoft


Once you click on the TMDL it will lead to a separate section with all the introductory steps. To start with, we will change the summarise by for all columns from none to sum. Just drag and drop the Sample Superstore table.


You can edit the none to Summarise by section for every column to Sum. Since we are in the world of automation let's do it like a PRO. Just select None and do Ctrl+F to find it everywhere in the view and replace it by Sum. Hit Apply and you will observe sigma sign appearing before all the columns.

Note: Ideally, summarise by property should be set to None to avoid the use of Implicit measures. As a best practice always use explicit measures. To know more about Implicit and Explicit measures, refer to the detailed article.

Isn't it amazing? Let's play around with our measures table and create a measure to calculate the Furniture sales. Simple measure with a filter on the Category.


Now, I want the different measures for different categories. In this case I only have 3 categories, ideally you can copy the same measure and create new measures. Then set the formatting for them individually. With TMDL you can achieve the same with less efforts. Once you have created a measure for Furniture  Sales it will look like this in TMDL view.


I want to create a similar measure for Office Supplies and provide a similar format string to both of them. Before we do it, line tags need to be removed and we copy the rest. Why we remove the line tag? Line tags are unique tag associated to a measure or field in the semantic model. If we copy the line tag it will lead to error as it needs to be unique. 


Hit apply and boom you will see there is another measure called Office Supplies Sales created. Now imagine you have tons of categories and you have to do it the old way it will take forever to create measures for all of them. But what about formatting each one of them. TMDL takes care of it too.

I have provided a basic fixed 2 decimal formatting to furniture sales and office supplies sales measure it will create a new line in TMDL view for format string. We need to switch to whole number instead of decimal numbers. Use Ctrl+F to find wherever we have the same formatting applied and replace it with #,0. Hit apply and you will see all measures formatting turned to whole numbers.


How amazing it is? Now let's do something more magical!!! We are looking to copy the entire list of measures from one PBIX to another. Drag your measure table in the TMDL script section. As mentioned, every measure comes up with a line tag if you just copy as it is then it will lead to errors. 

We need to remove all the line tags but I have a list of 63 measures. I am not looking to repeat my efforts for 63 times. Thanks to Fernan for helping us out here. Use Ctrl+F to find the line tags by typing this "^.*lineageTag: .*\n?" selecting the regular expression and replace it with blanks.


Hit apply and all line tags will be removed. Now simply open the new PBIX file where you need to copy the measures. Copy all the measures from TMDL view, and paste it in the new PBIX TMDL view. Hit apply and you have the same measures in both PBIX files.

How cool is this? let's take it to next level, I am looking provide a short description to different columns in my fact table. With TMDL, it is super easy. Go to the TMDL view and drag your fact table. Add just "///"and type a description.



Let's do one more thing to wrap today's blog. As a Power BI developer, we need to hide a certain columns.  Before TMDL, we do it in the data modelling. After TMDL, you can just add a line "is hidden" for a specific column. Hit apply and Ship mode is now hidden.


Amazing!!! we have covered only a limited scope for this blog but you can achieve a lot more with TMDL. It is great for source control and collaborative developments too. Do drop a comment if you want us to cover the source control in the upcoming blogs.


"All our articles are intended to address all the frequently asked questions related to a topic. Do leave a comment if it answers any of your question. "


Thanks for Reading Let's connect on LinkedIn. For more such blogs and pro tips do follow us

Comments

Popular posts from this blog

Identify and Delete Unused Columns & Measures

Heavy dashboards and a bad data model is a nightmare for every BI Developer. Heavy dashboards can be slow due to multiple reasons. It is always advised to stick with best practices. Are you still figuring out about those best practices then you should definitely have a quick read on Best Practice Analyser ( link ). One of the most common issues with slow dashboards is unused columns and unused measures.  It is very normal to load some extra columns and create some test measures in your dashboard but as a part of cleanup process those unused columns and unused measures should be removed. Why we are removing them? Because if you keep them then ultimately it will increase the size of your data model which is not a good practice.  How to identify the culprits (unused columns and unused measures)? In today's blog we will provide you with 2 most common external tools which will help you in identifying the culprits. More external tools😒. Who's going to pay for this? To your surprise...

Ultimate Beginners Guide to DAX Studio

There are zillions of external tools available with Power BI but DAX Studio is one of the most commonly used tools to work with DAX queries. It is a perfect tool to optimize the DAX and the data model. In this blog let's shed some light on the basic functionalities that can take your report to the next level. ARE YOU READY?  To start you will need the latest version of the DAX Studio. You can download it from their website . Don't worry you don't have to pay for the license. Fortunately, DAX Studio is a free tool As a BI Developer, I am using DAX Studio regularly. Based on my experience I use it for several purposes but in this blog, I will highlight the most common ones. Extracting a dump of all the measures used in your PBIX. Why do we need to do this? It can be used for documentation purposes also sometimes we try to reuse the DAX and such a dump comes in handy in this scenario. How to achieve it? Open the DAX Studio it is located under the external tools once you open t...

Best Practice Analyser (BPA) Guide

Do you want to save tons of efforts to check if your data model and PBIX file follows the standard best practices and norms? Then this blog is for you. If you are a follower of our channel we already deep dive into the importance of the DAX Studio as an external tool. If you are a beginner I would highly recommend to visit this blog . In today's blog we will check how Tabular Editor can help to optimize the data model.  Best Practice Analyser allows to define or import best practices. It will make sure that we do not violate the best practices while developing a dashboard. Isn't it exciting!! Before we start make sure you already have Tabular Editor version 2.24.1 installed on your system. To install it do visit this link and select the link for windows installer. Once Tabular Editor is installed it will reflect in your PBIX file under external tool. Also, we need to define the standard rules. To do so in your advanced scripting or C# script copy this and save it via Ctrl+S. An...