Power BI Semantic Model
Migrate a Power BI project, with its semantic model, DAX measures and reports, to anfra with a coding agent.
Upcoming
This integration is in development and not available yet.
If your semantic layer lives in a Power BI semantic model, you don't need to rebuild it from scratch. A coding agent with the migrate-power-bi skill reads your Power BI project and writes it as anfra data models, datasets and data apps. DAX measures become AQL metrics that run as SQL on your warehouse.
How it works
Power BI keeps modeling and reports in one project. anfra splits them into a semantic layer (models and datasets) and data apps that query it:
- Power BI Desktop
- Table — Data imported by Power Query (M)
- Semantic model — Relationships, DAX measures and calculated columns, saved as TMDL in a .pbip project
- Report — Report pages bound to one semantic model
- Publish — Power BI Service
- anfra
- Model — A .model.aml per table, reading straight from your warehouse
- Dataset — Relationships, AQL metrics and dimensions in a .dataset.aml
- Data app — An HTML page in apps/ that queries your datasets
- Publish — Share with your team on anfra BI Cloud
- pbi-table → pbi-model
- pbi-model → pbi-report
- pbi-report → pbi-publish
- anfra-model → anfra-dataset
- anfra-dataset → anfra-app
- anfra-app → anfra-publish
- pbi-table → anfra-model (Table → AML)
- pbi-model → anfra-dataset (TMDL + DAX → AML + AQL)
- pbi-report → anfra-app (Report → HTML)
Power BI concepts in anfra
| Power BI | anfra | Difference |
|---|---|---|
| Power Query (M) | Query model (type: 'query'), or upstream SQL or dbt | M loads data into Power BI on refresh. A query model is SQL that runs on your warehouse at query time. |
| Table | Model (.model.aml) | A Power BI table holds imported data. A model is only a definition, and the data stays in your warehouse. |
| Semantic model | Dataset (.dataset.aml) | A semantic model belongs to one workspace. A model can be reused in any number of datasets. |
| Relationship | Relationship | anfra works out the join path from the fields a query uses. |
| Measure (DAX) | Metric (AQL or SQL) | DAX depends on filter context. An AQL metric states what it filters and groups by. |
| Calculated column (DAX) | Dimension | A calculated column is stored on refresh. A dimension compiles into the SQL of each query. |
| Report | Data app | A report is bound to one semantic model. A data app can query several datasets. |
.pbip project folder | anfra project | TMDL and JSON become AML files and HTML apps, all in Git. |
DAX in AQL
The most common DAX patterns and their AQL equivalents:
| DAX | AQL |
|---|---|
CALCULATE([m], filter) | m | where(filter) |
CALCULATE([m], SAMEPERIODLASTYEAR(...)) | m | relative_period(<timestamp>, interval(-1 year)) |
CALCULATE([m], USERELATIONSHIP(...)) | m | with_relationships(...) |
CALCULATE([m], ALL(table)) | m | of_all(<model or dimension>) |
CALCULATE([m], ALLEXCEPT(table, keep)) | m | keep_grains(<dimension>) |
DIVIDE(a, b) | safe_divide(a, b) |
| Calculated table | Query model |
| Marked date table | Not needed. Period functions work on any date or timestamp field. |
Migrate a project
Step 1: Export to .pbip
In Power BI Desktop, turn off Auto date/time so LocalDateTable_* tables stay out of the export. Then go to File > Save As > Power BI Project (*.pbip). The project folder stores the semantic model as TMDL and the measures as DAX, in text files an agent can read.
Step 2: Set up anfra
Set up an anfra project, connect it to the warehouse your Power BI data comes from in .anfra/data_sources.yml, and set up your coding agent.
anfra queries your warehouse live. Data that Power BI imports from Excel or other files must be loaded into the warehouse first.
Step 3: Run the migration
Put the .pbip folder next to your anfra project and ask your agent. In Claude Code:
/anfra:migrate-power-bi migrate this Power BI project into anfraThe agent works through the project in order:
- Inventory: reads the TMDL, DAX, relationships and report JSON, and lists the warehouse tables.
- Models: writes one
.model.amlper Power BI table. - Dataset: writes a
.dataset.amlwith the models and their relationships. - Metrics: converts each DAX measure to an AQL metric.
- Data apps: rebuilds each report as an HTML app in
apps/. - Parity: runs the metrics across several dimension combinations and compares the totals with Power BI.
It runs anfra validate after each step.
Here's how the project folders compare:
power-bi-project/ anfra-project/
project.pbip models/
project.SemanticModel/ orders.aml
definition/ users.aml
model.tmdl active_users.aml
tables/orders.tmdl datasets/
tables/users.tmdl ecommerce.aml
expressions.tmdl (M code) apps/
project.Report/ sales.html
definition.pbir performance.html
report.jsonStep 4: Check the result
Before you share the result, check that:
anfra validatepasses.- The dataset joins the same tables as the Power BI semantic model.
- Each DAX measure has an AQL metric, and the totals match for a known date range.
- Inactive relationships used with
USERELATIONSHIPresolve to the same joins. - Each data app shows the same totals as its Power BI report.
Then publish to anfra BI to share the apps with your team.
Capabilities
| Capability | Support | Details |
|---|---|---|
| Tables, relationships and calculated columns | Supported | Converted to models, dataset relationships and dimensions. |
| DAX measures | Supported | Converted to AQL metrics, or SQL measures when AQL isn't a fit. |
| Reports | Supported | Rebuilt as data apps. |
| Power Query (M) | Not supported | Move the transformations to SQL or dbt in your warehouse, or to query models. |
| Alerts, subscriptions and embeds | Not supported | Not converted. |
| Write back to Power BI | Not supported | Changes in anfra are not written back to Power BI. |