Semantic Models
BimlFlex can generate Power BI Direct Lake semantic model definitions in TMDL (Tabular Model Definition Language) as part of a Microsoft Fabric Data Factory build. The same metadata that produces your Fabric pipelines also describes your dimensional model, and with semantic model generation enabled, the build writes semantic model definition folders alongside the rest of your Fabric output. Semantic model generation is included in the latest BimlFlex builds as an opt-in preview and is off by default.
:::info Preview Semantic model generation is an opt-in preview, disabled by default. The covered source binding is Direct Lake on OneLake. The build emits definition files as build output and does nothing beyond that. :::
Varigence has generated Analysis Services Tabular semantic models from metadata for years in BimlStudio, and semantic model generation brings that same discipline to Power BI Direct Lake on Fabric.
What a build emits
When semantic model generation is enabled, each Fabric Data Factory project in the build produces one semantic model, built from the dimension and fact objects in that project. Objects excluded from the model in metadata are left out, and a project with no dimension or fact objects produces no model.
Each model is written as a definition folder in the layout Fabric uses for semantic models in git:
<Name>.SemanticModel/
.platform
definition.pbism
definition/
database.tmdl
expressions.tmdl
model.tmdl
relationships.tmdl
tables/
<Table>.tmdl
There is one table file per dimension or fact. Tables carry directLake entity partitions bound to OneLake through a shared source expression, and relationships between the tables in the model are emitted from the references in your metadata.
The relationships.tmdl file is present only when the model has at least one relationship.
Table partitions bind to the physical table names in the lakehouse. Spark SQL on a schema enabled lakehouse stores table names in lowercase, so a table created as dbo.DimCustomer lands in OneLake as Tables/dbo/dimcustomer, and the emitted partition binds to dimcustomer while the table in the model keeps the name DimCustomer and column names keep their casing. Two tables in one lakehouse schema whose physical names differ only by case would bind to the same entity, so the build refuses the model with an error that names the schema, the physical names and the lowercase entity, and writes no files for it.
A model with the Direct Lake on OneLake flavor writes directLakeBehavior: directLakeOnly in model.tmdl. A model with the Direct Lake on SQL flavor writes no directLakeBehavior line, so it takes the default of automatic with DirectQuery fallback.
definition.pbism carries version 4.2, and the TMDL files follow the property order the Fabric service writes, with a trailing blank line on each file, so a definition folder synced to a workspace through git shows no diff after the first commit back.
Each model column carries a data type mapped from its data warehouse column. A decimal column with at most 4 decimal places and at most 15 integer digits (precision less scale), such as Decimal(19,4), maps to the engine's fixed decimal type and is written as dataType: decimal. Any other decimal column, such as Decimal(18,2) or a decimal column with no precision or scale in metadata, is written as dataType: double, and the build reports a warning that names the column. A column of exactly 15 integer digits that holds a value above the engine's largest fixed decimal value, 922,337,203,685,477.5807, fails processing with no build warning.
Enabling and configuring
The feature is enabled and configured from the settings editor. The settings live in the Microsoft Fabric group:
| Setting | Default | Behavior |
|---|---|---|
SemanticModelEnable | N | Turns semantic model generation on for the build. When disabled or blank, no semantic model output is produced. |
SemanticModelOutputPath | @@OutputPath/SemanticModels | Where the definition folders are written. The @@OutputPath token resolves to the build output folder. |
SemanticModelFlavor | DirectLakeOnOneLake | The Direct Lake source binding for the model. A blank value resolves to the default. A project-scoped value overrides the instance-level value. |
SemanticModelName | blank | The model name. Blank means the project name is used. The resolved name becomes the Name.SemanticModel folder name and the display name in the .platform file. |
SemanticModelDescription | blank | A description written to the generated model's .platform metadata. Blank means no description property is written. |
When an instance has more than one Fabric project, set SemanticModelName per project. An instance-level name resolves to the same value for every project, and models whose resolved names collide are skipped with a build error so their output folders cannot overwrite each other.
The Import flavor
SemanticModelFlavor accepts three values: DirectLakeOnOneLake, DirectLakeOnSql and Import. The Import flavor writes the semantic model folder of a Power BI project, with import partitions that load the tables of the project's SQL Server data mart through Power Query, for Power BI Desktop and the Power BI service. It is not an Analysis Services deployment: a model for SQL Server Analysis Services comes from the SSAS Tabular output.
Under the Import flavor, every project with dimension or fact objects produces a model, whatever its integration template. Each model is written as the semantic model folder of a Power BI project:
<Name>.SemanticModel/
definition.pbism
definition/
database.tmdl
expressions.tmdl
model.tmdl
relationships.tmdl
tables/
<Table>.tmdl
definition.pbism carries version 4.0, database.tmdl carries compatibilityLevel 1600, and the folder has no .platform file. Every table loads through an import partition. The Power Query expression of each partition navigates one shared DatabaseQuery source to the table by schema and name, and DatabaseQuery is defined once in expressions.tmdl as a Sql.Database source on the server and database of the data mart. Repointing the whole model at another server is one edit in one file.
Tables, measures, hierarchies and relationships follow the same object selection and metadata overrides as the Direct Lake flavors.
Settings for the Import flavor
The settings in the Microsoft Fabric group apply to every integration template. An Import model uses them as follows:
| Setting | Value for an Import model |
|---|---|
SemanticModelEnable | Y. |
SemanticModelFlavor | Import, at project or instance scope. A project value overrides the instance value, and a blank value resolves to DirectLakeOnOneLake. |
SemanticModelName | Optional. Blank means the project name is used. Two projects that resolve to the same name report an error, and neither model is written. |
SemanticModelOutputPath | Where the folders are written, @@OutputPath/SemanticModels by default. |
SemanticModelDescription | No effect on an Import model. |
A project with dimension or fact objects whose SemanticModelFlavor value is not one of the three values reports an error and writes no model, whatever its integration template.
The source connection
The server and database come from the connection string of the project's data mart: Data Source or Server names the server, and Initial Catalog or Database names the database. A model reads one server and database pair, and a model whose objects span two pairs reports an error.
The data mart must be on SQL Server, Azure SQL Database or Azure Synapse. A Databricks connection string does not resolve in Sql.Database.
A project outside Microsoft Fabric reads the data warehouse tables and column names of its target connection. A Microsoft Fabric project keeps the tables of its endpoint.
Opening an Import model in Power BI Desktop
- Save a report in Power BI Desktop as a Power BI project (
.pbip). - Place the generated
<Name>.SemanticModelfolder beside it. - Point the report's
definition.pbirat the generated folder. - Open the
.pbipfile. - Enter the SQL Server credentials when prompted, then refresh.
KPIs and perspectives
Four metadata attribute keys add KPIs, perspectives and data categories to a model: semantic.kpi, semantic.kpiStatus, semantic.perspective and semantic.dataCategory. The keys apply to every semantic model output. The Direct Lake and Import models and the SSAS Tabular model carry the same KPIs, perspectives and data categories from the same metadata.
| Key | Level | Value | Property | Description |
|---|---|---|---|---|
semantic.kpi | Table or column | The name of a measure of the same table, a generated measure or one declared with semantic.measure | The target DAX expression | The KPI description |
semantic.kpiStatus | Table or column | The measure name | The status DAX expression | The status graphic name. Blank means TrafficLightSingle. |
semantic.perspective | Table | The perspective name | ||
semantic.dataCategory | Table or column | Time on a table, or one of the fourteen column categories on a column | On a table, the name of the date column. Blank means the table's single date column. |
The first three keys can appear more than once. A table or column carries one semantic.dataCategory value, and when the key appears more than once the last one applies.
KPIs
A KPI needs both a semantic.kpi key and a semantic.kpiStatus key for its measure. A KPI without its status key is left out of the model with a warning that names the measure.
The status graphic is one of TrafficLightSingle, ThreeFlagsColored, RoadSigns, TrafficLight, ThreeSymbolsUncircledColored, Shapes, ThreeStarsColored, FiveBarsColored, FiveBoxesColored or GaugeAscending, matched ignoring case.
In the Direct Lake and Import models, each KPI is a kpi block under its measure in the table file.
Perspectives
A model with two or more facts carries one perspective per fact without any key. Each of these perspectives is named after its fact and holds the fact and every dimension a relationship leads to from it, with every column, measure and hierarchy of those tables. A model with one fact carries no derived perspective.
When two facts have names that differ only in case, each model names the second perspective with a numeric suffix and reports one warning of its own that names both facts and the suffixed name. A model with the facts Inventory and inventory holds the perspectives Inventory and inventory 2. Give the two facts object names that differ by more than case.
A semantic.perspective key adds its table to the perspective of that name, matched ignoring case, and creates the perspective when no fact derives one of that name. The key is a table level key. On a column it is ignored with a warning, so set it on the table instead.
A semantic.perspective key whose name matches a suffixed perspective name when case is ignored is renamed as well, and the build reports a warning that says to give the key a name no other perspective of the model uses.
In the Direct Lake and Import models, each perspective is a document in definition/perspectives/ with a ref perspective line in model.tmdl. The build writes files and never deletes them, so in a definition folder synced to a Fabric workspace through git, the perspective document of a fact that leaves the model stays until the folder is cleaned.
Data categories
semantic.dataCategory with the value Time on a dimension marks it as the model's date table. The DAX time intelligence functions need a date table when the relationship from a fact runs on an integer date key. On the marked table the date column becomes the table's key in place of the integer primary key, because the engine allows one key column per table and a date table's key is its date column. Relationships keep the columns they join on, so the relationship on the integer key stays as it is.
The date column is the column of the dateTime data type whose metadata name the key's property names, matched ignoring case. With a blank property, the date column is the table's single column of the dateTime data type, and the system columns BimlFlex adds, such as the row start and end dates, do not count. When the property names no dateTime column of the table, or a blank property finds no such column or more than one, the build reports a warning that names the table, and the category is not written.
The property names a business column of the table. When the property names a system column, such as the row start and end dates, the build reports a warning that names the table and the column and states that a system column does not carry the date table key, and the category is not written.
On a column, the value is one of the fourteen Power BI column categories: Address, City, Continent, Country, County, Image, ImageUrl, Latitude, Longitude, Organization, Place, PostalCode, StateOrProvince or WebUrl. The value is matched ignoring case and written in the engine's casing, so postalcode is written as PostalCode.
Any other value gives a build warning and writes nothing: a value other than Time on a table, or a value outside the fourteen categories on a column, Time included. Time on a fact table also gives a warning and writes nothing, because a date table is a dimension. The warning names the table, and the column when the key is on a column. Where the build warns, the table and its key stay as they would be without semantic.dataCategory. Uncategorized on a column writes nothing and gives no warning.
In the Direct Lake and Import models, the table file carries dataCategory: Time in the table block and isKey on the date column, and dataCategory: <Category> in the block of each column with a category. The deployed model carries the table and column categories.
The build does not check that the date column holds unique, contiguous dates at day grain. Power BI makes that check when you mark a date table yourself, and a date dimension at day grain meets it by construction. The key leaves sort order alone, so a date column that sorts by the integer key keeps that sort.
How output is verified
Emitted output is checked for compatibility with Microsoft's publicly available Tabular Object Model library. That check is compatibility verification, not a certification or endorsement by Microsoft.
Generation is deterministic. The same metadata produces the same output on every build.
Deploying and operating a model
The build writes the definition folders and nothing more. Deploying a folder to a Microsoft Fabric workspace and keeping the model served is the operator's work, and this section describes what happens at each step.
Fabric capacity
Direct Lake needs a Fabric capacity, either an F SKU or a trial. On a paused capacity every call to the model fails, including definition reads and queries.
Deploying the definition folder
A workspace connected to git accepts the emitted folder as it is, and the Fabric REST API accepts the same folder unmodified in a create semantic model call and in an update definition call. The build writes compatibilityLevel 1604 in database.tmdl. Both 1604 and 1702 are accepted, and neither is rewritten by the service.
The build writes files and never deletes them, so in a definition folder synced to a Fabric workspace through git a renamed table leaves its old table file beside the new one, and a model that loses its last relationship leaves its old relationships.tmdl in place. Those files stay until the operator removes them or resets the folder.
The first refresh
A Direct Lake model answers queries only once a refresh has framed it, and that refresh is metadata only. A newly deployed Direct Lake on OneLake model arrives unframed, and because the model is emitted with directLakeBehavior: directLakeOnly the first query fails instead of framing on demand. The message depends on the client: the portal reports that the table is not refreshed and fallback to DirectQuery is disabled, and a query through the REST API reports that it cannot find the table. Run one refresh after the first deploy, from the semantic model's Refresh now action in the portal or with a POST to datasets/{id}/refreshes. A metadata only redeploy of an already framed model does not unframe it, so no further refresh is needed after an update definition call on that model.
Source table timing
Right after a Delta table is created or renamed, a refresh can fail for a few minutes with the message that one or multiple source tables either do not exist or access was denied, even though the table folders exist in OneLake. Nothing is wrong with the model. Retry the refresh after a few minutes.
Renamed source tables
If a source table is renamed in the lakehouse, the next refresh fails with DirectLake_TableNotFound and the table leaves the served model. Queries that do not touch that table keep working, and the definition stored in the workspace is unchanged. The table returns by itself once the physical table is back and a refresh succeeds. No redeploy is needed.
Boundaries
- Semantic model generation is an opt-in preview and is off by default.
- The covered source binding is Direct Lake on OneLake.
- The build writes semantic model definition folders into the build output and nothing more.