Creating Measure Tables in Microsoft Fabric Semantic Models

Measure Tables have long been used to store Measures in Power BI Semantic Models.

However, in Microsoft Fabric, where most of the data modeling takes place in the browser, at least if we wish to reap the benefits of the DirectLake storage mode, the process of creating Measure Tables are slightly different.

Step 1: Creating an empty table

First you need to create an empty table. Or rather, a table with one column in it (a table can’t have zero columns in Fabric), but you should not add any data to this table.

If the Data Lakehouse is your weapon of choice, you may use a Notebook to do so with Python:

data = [(1, 'MeasureTable')]
columns = ['ID', 'Col1']

measure_df = spark.createDataFrame(data, columns)
measure_df.show()

spark.sql("DROP TABLE IF EXISTS MeasureTable")
measure_df.write.format("delta").saveAsTable('MeasureTable')

If you are using the Lakehouse SQL Endpoint you can create an empty view, or if you are using Data Warehouse, create a table with SQL:


Step 2: Pulling the table into your Semantic Model

The next step is to create a Semantic Model on top of your Warehouse or Lakehouse:

And subsequently, add a couple of measures, before finally hiding the only column present in the table, to convert it into a Measure Table:

And there you have it! It is that simple to create centralized measure tables in your Microsoft Fabric semantic models. Go build!

One response to “How to create Measure Tables in Microsoft Fabric”

  1. So weird that there’s not a standard Measure table in the model and that you instead have to create an empty table and push that around in your deployments as well.

    Like

Leave a comment

Blog at WordPress.com.