From Apache Ossie to a Power BI project: trying out my first Apache Ossie contribution

From Apache Ossie to a Power BI project: an Apache Ossie YAML metric, Total Sales with SUM(Amount), becomes the DAX measure SUM('Sales'[Amount]) in a TMDL file

My first contribution to Apache Ossie (incubating) has been merged. PR #76 adds a new export to the Microsoft Power BI converter: an Apache Ossie semantic model can now be written as the semantic model folder of a Power BI project (PBIP), as split TMDL. That’s the format teams keep in Git, and the one Power BI Desktop, Fabric Git integration and fabric-cicd read.

This post walks through a step-by-step example, with screenshots, that you can follow on your own machine.

What is Apache Ossie?

Apache Ossie (formerly Open Semantic Interchange, OSI) is a vendor-neutral YAML format for semantic models: datasets, fields, metrics and relationships. The ossie-converters repository has converters between Ossie and tools like Snowflake, Databricks, dbt, BigQuery and Power BI. The Microsoft converter already turned an Ossie model into a single model.bim (TMSL) file or a single TMDL document. What was missing was the folder layout that real Power BI projects use.

What the feature does

ossie-microsoft export -i model.yaml --pbip out/ # writes out/<name>.SemanticModel/
ossie-microsoft export -i model.yaml --pbip out/ --force # replaces the definition of an existing folder
ossie-microsoft export -i model.yaml --pbip Sales.SemanticModel # writes into that folder itself
from ossie_microsoft import export_powerbi_project
folder = export_powerbi_project(ossie_yaml, "out/") # returns out/<name>.SemanticModel

The output looks like this:

out/<name>.SemanticModel/
definition.pbism
definition/
database.tmdl model.tmdl relationships.tmdl expressions.tmdl
tables/ roles/ cultures/ perspectives/

A few design decisions:

  • TOM writes the TMDL. The converter builds the model with its existing TMSL export, then hands it to Microsoft’s Tabular Object Model (TmdlSerializer.SerializeDatabaseToFolder). No TMDL is written by hand, so the layout is exactly what Power BI produces.
  • definition.pbism uses version 4.0, the first version that reads the model from definition/ instead of model.bim.
  • Safe overwriting. A non-empty folder is refused unless you pass --force. With --force, only definition.pbism and definition/ are replaced, so Desktop’s own files (.pbi/, diagramLayout.json, .platform) survive, and you can re-export into a project that Power BI created.
  • TMSL projects are never switched. A folder that stores its model as model.bim is refused even with --force.
  • Same reporting as before. Anything that can’t be converted faithfully is reported on stderr, and --strict turns it into a non-zero exit.

Try it yourself: from YAML to Power BI, step by step

In this walkthrough you build a tiny sales model as Apache Ossie YAML, export it as a Power BI project, open it in Power BI Desktop, change it, and watch the change show up in Git. Everything runs offline: the sample data is embedded in the model, so you don’t need a database.

The model has two tables (Product and Sales), one relationship and four metrics.

What you need

  • Windows 10 or 11 with Power BI Desktop
  • Git
  • uv, the Python package manager, which also installs a suitable Python for you: powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
  • The .NET 8 SDK, because the converter uses Microsoft’s Tabular Object Model (TOM) to write TMDL: winget install Microsoft.DotNet.SDK.8

Step 1: Get the converter

Clone the repository and install the converter with its optional TOM support:

git clone https://github.com/apache/ossie-converters.git
cd ossie-converters\microsoft
uv sync --extra tom
uv run python scripts/restore_tom.py

uv sync installs the converter. restore_tom.py downloads Microsoft’s Microsoft.AnalysisServices libraries from NuGet into a local .tom folder. They are Microsoft-licensed, so they are never committed to the repository.

PowerShell running uv sync --extra tom and restore_tom.py
The TOM libraries are restored into .tom\assemblies. I cloned the repository to C:\src; your path may differ.

Step 2: Describe the model in YAML

Create a tutorial folder inside ossie-converters\microsoft, and save this as tutorial\contoso_sales.yaml:

version: 0.3.0.dev0
name: contoso_sales
description: A tiny sales model for trying the Power BI project export.
datasets:
- name: Product
source: Product
primary_key: [ProductKey]
fields:
- name: ProductKey
datatype: Integer
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: ProductKey
- name: Product
datatype: String
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: Product
- name: Category
datatype: String
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: Category
# Demo data, so Power BI Desktop can load the model without a database.
nonportable_extensions:
- vendor_name: POWER_BI
data:
partitions:
- name: Product
mode: import
source:
type: m
expression: |-
let
Source = #table(
type table [ProductKey = Int64.Type, Product = text, Category = text],
{
{1, "Road Bike", "Bikes"},
{2, "Mountain Bike", "Bikes"},
{3, "Helmet", "Accessories"},
{4, "Water Bottle", "Accessories"}
}
)
in
Source
- name: Sales
source: Sales
fields:
- name: OrderID
datatype: Integer
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: OrderID
- name: OrderDate
datatype: Date
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: OrderDate
- name: ProductKey
datatype: Integer
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: ProductKey
- name: Quantity
datatype: Integer
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: Quantity
- name: Amount
datatype: Float
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: Amount
nonportable_extensions:
- vendor_name: POWER_BI
data:
partitions:
- name: Sales
mode: import
source:
type: m
expression: |-
let
Source = #table(
type table [OrderID = Int64.Type, OrderDate = date, ProductKey = Int64.Type, Quantity = Int64.Type, Amount = number],
{
{1001, #date(2026, 1, 5), 1, 1, 1200},
{1002, #date(2026, 1, 9), 3, 2, 90},
{1003, #date(2026, 2, 14), 2, 1, 950},
{1004, #date(2026, 2, 20), 4, 5, 50},
{1005, #date(2026, 3, 2), 1, 2, 2400},
{1006, #date(2026, 3, 18), 3, 1, 45}
}
)
in
Source
relationships:
- name: sales_to_product
from: Sales
to: Product
from_columns: [ProductKey]
to_columns: [ProductKey]
metrics:
- name: Total Sales
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: SUM(Amount)
# Power BI keeps measures on a table; this puts them on Sales.
nonportable_extensions:
- vendor_name: POWER_BI
data: {table: Sales}
- name: Total Quantity
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: SUM(Quantity)
nonportable_extensions:
- vendor_name: POWER_BI
data: {table: Sales}
- name: Order Count
expression:
nonportable_dialects:
- dialect: ANSI_SQL
expression: COUNT(OrderID)
nonportable_extensions:
- vendor_name: POWER_BI
data: {table: Sales}
- name: Average Order Value
expression:
nonportable_dialects:
- dialect: DAX
expression: DIVIDE([Total Sales], [Order Count])
nonportable_extensions:
- vendor_name: POWER_BI
data: {table: Sales}

How to read it:

  • datasets, fields, relationships and metrics are plain, vendor-neutral Apache Ossie. Any Ossie tool can read them.
  • Three metrics are written in SQL (SUM(Amount)). The converter translates them to DAX for you. Average Order Value is written in DAX, to show that a metric can carry the dialect a tool needs.
  • The nonportable_extensions blocks with vendor POWER_BI are extras that only Power BI uses. Here they embed the demo data as Power Query #table expressions, and they tell Power BI to put the measures on the Sales table. Remove them and the file is still a valid Ossie model; you’d just need a real data source.
  • Each expression lists its forms under nonportable_dialects, one entry per SQL or DAX dialect. Documents written for earlier versions of the spec call this list dialects; current versions of Apache Ossie and the converter need the new name.

Step 3: Export it as a Power BI semantic model

uv run ossie-microsoft export --strict -i tutorial/contoso_sales.yaml --pbip tutorial/out
The export command printing Wrote tutorial\out\contoso_sales.SemanticModel
The export names the folder it wrote. With –strict, it would stop with a non-zero exit if anything couldn’t be converted faithfully.

The folder name comes from the model’s name, so the result lands in tutorial\out\contoso_sales.SemanticModel.

Step 4: Look inside

tree /F tutorial\out
The exported folder: definition.pbism and a definition folder of TMDL files
The same split TMDL layout Power BI Desktop writes: one file per table, plus the model, its relationships and definition.pbism.

Open tables\Sales.tmdl in any editor. The SQL metrics are now DAX measures, and the original SQL is kept as annotations, so it isn’t lost:

Sales.tmdl showing measure Total Sales = SUM('Sales'[Amount]) with annotations
SUM(Amount) became SUM(‘Sales'[Amount]). The OssieExpression annotations keep the original SQL.

Step 5: Open it in Power BI Desktop

A .pbip project also needs a report, and the export only writes the semantic model. The easiest way is to let Power BI Desktop create an empty project, then export into it.

1. Create an empty project. Open Power BI Desktop with a blank report and choose File > Save as. Set the file type to Power BI project files (*.pbip) and save it as ContosoSales.pbip in your tutorial folder. In older versions of Desktop, first turn on Power BI Project (.pbip) save option and Store semantic model using TMDL format under File > Options and settings > Options > Preview features.

Power BI Desktop Save As dialog with the file name ContosoSales and Save as type set to Power BI project files (*.pbip)
Save the blank report as a Power BI project (*.pbip). Your folder will be different.

2. Close Power BI Desktop. Desktop holds the project open and would write its own model back when you save.

3. Export into the project’s semantic model folder. Point --pbip at the .SemanticModel folder Desktop created. The first try is refused, because the folder isn’t empty. --force replaces only the model definition:

uv run ossie-microsoft export --strict -i tutorial/contoso_sales.yaml --pbip tutorial/ContosoSales.SemanticModel --force
Export refused without --force, accepted with --force, and the folder tree afterwards
Without –force the export refuses to touch an existing model. With –force, Desktop’s own files (.platform, .pbi, diagramLayout.json) stay in place next to the new definition.

4. Open tutorial\ContosoSales.pbip. If Desktop says the data needs to be refreshed, click Refresh.

Power BI Desktop Model view: the Sales table, with its columns and the Average Order Value, Order Count, Total Quantity and Total Sales measures, related many to one to the Product table
The Model view: the relationship and all four measures came from the YAML. Sales is on the many side, Product on the one side.

Add a Table visual with Category, Total Sales, Order Count, Total Quantity and Average Order Value. You should see:

CategoryTotal SalesOrder CountTotal QuantityAverage Order Value
Accessories185.003861.67
Bikes4,550.00341,516.67
Total4,735.00612789.17
A Table visual by Category: Accessories 185.00, 3, 8, 61.67; Bikes 4,550.00, 3, 4, 1,516.67; Total 4,735.00, 6, 12, 789.17
The four Apache Ossie metrics, now DAX measures, computed by Power BI. The numbers match the table above.

Step 6: Change the model and see it in Git

This is why the PBIP format matters: the model is plain text, so Git can show exactly what changed. Close Power BI Desktop, then save the current version in Git (a separate repository, just for this demo):

git init tutorial
git -C tutorial add ContosoSales.SemanticModel

Now add a fifth metric at the end of tutorial\contoso_sales.yaml:

  - name: Largest Sale
    expression:
      nonportable_dialects:
        - dialect: ANSI_SQL
          expression: MAX(Amount)
    nonportable_extensions:
      - vendor_name: POWER_BI
        data: {table: Sales}

Export again with --force and look at the diff:

uv run ossie-microsoft export --strict -i tutorial/contoso_sales.yaml --pbip tutorial/ContosoSales.SemanticModel --force
git -C tutorial diff --stat
git -C tutorial diff
git diff after re-exporting: only Sales.tmdl changed, with a new Largest Sale measure
One new metric, one changed file, six added lines. Exactly the kind of change you’d review in a pull request.

Open ContosoSales.pbip again: the new Largest Sale measure is there and returns 2,400 overall (90 for Accessories).

The same Table visual with a Largest Sale column: Accessories 90.00, Bikes 2,400.00, Total 2,400.00
After the re-export, Largest Sale sits next to the other measures, and the report didn’t need any changes.

Step 7: Bring it back to YAML

The converter also works the other way. Import the project, and ask it to translate the DAX measures back to SQL where the translation is exact:

uv run ossie-microsoft import -i tutorial/ContosoSales.pbip --translate-dax -o tutorial/roundtrip.yaml
roundtrip.yaml in an editor: metric Total Sales has two nonportable_dialects, OSSIE_SQL_2026 SUM(Sales.Amount) and DAX SUM('Sales'[Amount])
Each metric comes back with both a SQL and a DAX expression. Even Average Order Value translates, to SUM(Sales.Amount) / NULLIF(COUNT(Sales.OrderID), 0).

The import reads the .pbip, follows it to the semantic model, and writes an Ossie document that other tools, such as the Snowflake, Databricks or dbt converters, can work with.

If something goes wrong

  • TOM assemblies are unavailable: run uv run python scripts/restore_tom.py again from the microsoft folder, and check that dotnet --version shows 8 or later.
  • stores its model as TMSL (model.bim): your Desktop project saved its model as model.bim. Turn on Store semantic model using TMDL format in Desktop, then save the project again, or delete model.bim from the .SemanticModel folder.
  • already exists and is not empty: add --force to replace the model definition. Only definition.pbism and definition/ are replaced.
  • An Application Control policy has blocked this file: Windows (Smart App Control or a company policy) blocked the small, unsigned ossie-microsoft.exe launcher that uv creates. Run the converter through Python instead: replace uv run ossie-microsoft with uv run python -m ossie_microsoft.cli in every command, for example uv run python -m ossie_microsoft.cli export --strict -i tutorial/contoso_sales.yaml --pbip tutorial/out.
  • metric has no expression; skipped: the YAML uses the old dialects key. Apache Ossie renamed the list of an expression from dialects to nonportable_dialects, so rename dialects: to nonportable_dialects: under every expression.
  • Desktop still shows the old model: close Desktop completely before exporting, then reopen the .pbip.

What’s next

  • Microsoft just announced semantic views in Fabric, the first Fabric feature built on Apache Ossie. A PBIP export gives you a full, editable Power BI model for Git and CI/CD, while a semantic view is a lightweight, read-only layer on a lakehouse. They work well together, and a Fabric semantic view export target could be a good next step for the converter.

If you work with Power BI and semantic models, give the converter a try and open an issue with what you find.

Links

Comments

One response to “From Apache Ossie to a Power BI project: trying out my first Apache Ossie contribution”

  1. Jon Avatar
    Jon

    Love it, what a fantastic project enabling the use of SaaS innovation without the lock-in ⭐️

Leave a Reply