anfra docsAlpha
Semantic layerExisting semantic layers

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:

Migrating Power BI to anfra
  • 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 BIanfraDifference
Power Query (M)Query model (type: 'query'), or upstream SQL or dbtM loads data into Power BI on refresh. A query model is SQL that runs on your warehouse at query time.
TableModel (.model.aml)A Power BI table holds imported data. A model is only a definition, and the data stays in your warehouse.
Semantic modelDataset (.dataset.aml)A semantic model belongs to one workspace. A model can be reused in any number of datasets.
RelationshipRelationshipanfra 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)DimensionA calculated column is stored on refresh. A dimension compiles into the SQL of each query.
ReportData appA report is bound to one semantic model. A data app can query several datasets.
.pbip project folderanfra projectTMDL and JSON become AML files and HTML apps, all in Git.

DAX in AQL

The most common DAX patterns and their AQL equivalents:

DAXAQL
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 tableQuery model
Marked date tableNot 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 anfra

The agent works through the project in order:

  1. Inventory: reads the TMDL, DAX, relationships and report JSON, and lists the warehouse tables.
  2. Models: writes one .model.aml per Power BI table.
  3. Dataset: writes a .dataset.aml with the models and their relationships.
  4. Metrics: converts each DAX measure to an AQL metric.
  5. Data apps: rebuilds each report as an HTML app in apps/.
  6. 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.json

Step 4: Check the result

Before you share the result, check that:

  • anfra validate passes.
  • 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 USERELATIONSHIP resolve 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

CapabilitySupportDetails
Tables, relationships and calculated columnsSupportedConverted to models, dataset relationships and dimensions.
DAX measuresSupportedConverted to AQL metrics, or SQL measures when AQL isn't a fit.
ReportsSupportedRebuilt as data apps.
Power Query (M)Not supportedMove the transformations to SQL or dbt in your warehouse, or to query models.
Alerts, subscriptions and embedsNot supportedNot converted.
Write back to Power BINot supportedChanges in anfra are not written back to Power BI.

On this page