top of page

Getting Started with TMDL View in Power BI: My Experience

Jihwan Kim

In this writing, I want to share how I start to use the TMDL (Tabular Model Definition Language) view in Power BI.


This isn’t a deep dive into what TMDL View is, but rather a hands-on look at how I began using it and why I found it valuable. If you're interested in learning more about the technical details of TMDL View, check out the official documentation linked below:



TMDL view is introduced in the January 2025 update of Power BI Desktop. When I first saw I thought about how it could help me achieve things that previously required external tools like Tabular Editor 2 or 3. One of the first use cases that came to mind was defining DETAILROWS Definition in the data model and leveraging it within the DETAILROWS DAX function.



Below, I outline the steps you can follow to start using the TMDL view and apply it effectively in your Power BI models. Stay with me as I walk you through my experience!




Step 1: Enable the TMDL View Preview Feature in Power BI Desktop




Step 2. Create a sample model.




Step 3: Write a DAX Query in the DAX Query View to Define New Measures


In the DAX query below, I applied a filter to display only data for France. This filtering condition is placed inside the SUMMARIZECOLUMNS function, specifically using the FILTER function to restrict the Country table to only include France in the result. However, this condition is not applied within the measures themselves. Instead of embedding the country filter directly inside each measure, it is used at the query level within SUMMARIZECOLUMNS to filter the dimension table.

This approach keeps the measures reusable and flexible, allowing them to be applied across different contexts without being tied to a specific country filter.


DEFINE
	MEASURE 'Financials'[Sales total:] = SUM(Financials[ Sales])
	MEASURE 'Financials'[Gross Sales total:] = SUM(Financials[Gross Sales])
	MEASURE 'Financials'[COG:] = SUM(Financials[COGS])
	MEASURE 'Financials'[Profit:] = SUM(Financials[Profit])

EVALUATE
	SUMMARIZECOLUMNS(
		Country[Country],
		'Product'[Product],
		FILTER(
			Country,
			Country[Country] = "France"
		),
		"Sales", [Sales total:],
		"Gross sales", [Gross Sales total:],
		"Cost", [COG:],
		"Profit", [Profit:]
	)
	ORDER BY [Profit] DESC

And now, I want to incorporate the filtering condition directly inside the measures.

What if I want the measures to return results only for France, without relying on a filter in the SUMMARIZECOLUMNS function?



Step 4: Navigate to TMDL View and Enter the Following Script


The following script defines the DETAILROWS Definition in the data model. Ensure that proper indentation is maintained at the beginning of each line for accuracy.



Once applied and created, it will appear as shown below.


When you drag and drop the newly created item, you’ll notice that a new lineageTag is generated for it, as illustrated below.


Now, DETAILROWS definition is created.




Step 5: Create new measures by using the DETAILROWS DAX function to embed the filter directly into the measures.


As shown in the image below, the results of the new measures display only France-related numbers, without the need for external filters in the SUMMARIZECOLUMNS function.


DEFINE
	MEASURE 'Financials'[Sales France: ] = CALCULATE([Sales total:],KEEPFILTERS(DETAILROWS([_dre_france_filter])))
	MEASURE 'Financials'[Gross Sales France: ] = CALCULATE([Gross Sales total:],KEEPFILTERS(DETAILROWS([_dre_france_filter])))
	MEASURE 'Financials'[COG France: ] = CALCULATE([COG:],KEEPFILTERS(DETAILROWS([_dre_france_filter])))
	MEASURE 'Financials'[Profit France: ] = CALCULATE([Profit:],KEEPFILTERS(DETAILROWS([_dre_france_filter])))

EVALUATE
	SUMMARIZECOLUMNS(
		Country[Country],
		'Product'[Product],
		"Sales", [Sales total:], "Sales France", [Sales France: ],
		"Gross sales", [Gross Sales total:], "Gross sales France", [Gross Sales France: ],
		"Cost", [COG:], "Cost France", [COG France: ],
		"Profit", [Profit:], "Profit France", [Profit France: ]
	)
	ORDER BY [Profit] DESC


Summary


I shared how I start to use the TMDL View feature in Power BI Desktop to create a DETAILROWS definition. Previously, creating a DETAILROWS definition required external tools like Tabular Editor 2. However, with the introduction of TMDL view, I can now define DETAILROWS definition without relying on external tools. This opens up new possibilities for building complex DAX measures with embedded filter logic, all within the Power BI Desktop environment.

The benefit of this approach is the enhanced flexibility and efficiency it provides. Now, I can define and utilize DETAILROWS directly within Power BI Desktop, streamlining the process and eliminating the need for third-party tools. I will continue using Tabular Editor 3, but this enhancement makes Power BI more self-contained and accessible, particularly for users who may not be familiar with or have access to external tools.


I hope this helps make your experience with the TMDL view feature in Power BI Desktop enjoyable as you get started.

59 views0 comments

Recent Posts

See All

Comments


bottom of page