Databases
Power BI Semantic Models in VS Code
Overview
Section titled “Overview”Power BI semantic models define tables, relationships, measures, calculations, and business rules for analytical queries. DBCode uses paginated Power BI REST calls to discover workspaces and semantic models, then uses the Arrow-based Execute DAX Queries API as its only query transport.
Power BI Semantic Models is separate from DBCode’s Microsoft Fabric driver:
- Power BI Semantic Models queries semantic models with DAX and exposes model metadata.
- Microsoft Fabric connects to relational Warehouse and Lakehouse SQL endpoints over TDS and uses T-SQL.
One DBCode connection targets one Power BI workspace. Each semantic model in that workspace appears as a database. Semantic models do not expose queryable schemas, so their tables appear directly under the model.
Prerequisites
Section titled “Prerequisites”Before connecting, confirm that:
- The semantic model is assigned to a supported Power BI capacity: Premium, Fabric, or Embedded. A Fabric trial capacity can be used for evaluation.
- A Power BI or Fabric administrator has enabled Dataset Execute Queries REST API and Allow XMLA endpoints and Analyze in Excel with on-premises semantic models in the tenant’s Integration settings. See Integration admin settings.
- Your identity can discover the workspace and semantic model. Delegated credentials require the
Workspace.Read.Allscope documented by Get Groups. Service principals use the Power BI tenant and workspace permissions described below. - Your identity has Read and Build permissions on the semantic model. See Semantic model permissions.
The Arrow-based API used by DBCode is available only for semantic models on capacity. Microsoft describes this requirement in the Execute DAX Queries best practices.
Connecting
Section titled “Connecting”To connect:
- Open DBCode and add a connection.
- Select Power BI Semantic Models.
- In VS Code, select Microsoft sign-in (temporary). Default credentials and compatible DBCode authentication profiles are also available.
- Select a workspace. A connection is scoped to this one workspace.
- Select a semantic model. DBCode treats it as the connection’s database.
- Save the connection and start exploring.
The temporary Microsoft sign-in uses VS Code’s built-in authentication flow with Microsoft’s Power BI PowerShell client. It requests only the delegated Workspace.Read.All and Dataset.Read.All scopes needed by this driver. VS Code manages the token, and DBCode connects directly to Microsoft’s Power BI APIs. This Preview path will be replaced with DBCode’s own Microsoft client registration.
Default credentials support service principals, managed identities, and compatible Azure CLI credentials. The selected identity must be able to obtain a Power BI token and must have access to the workspace and semantic model.
Authentication profiles
Section titled “Authentication profiles”DBCode authentication profiles can provide a compatible OAuth2 or command-sourced Power BI access token. This is useful when an organization already has a supported Power BI authentication flow that should remain outside the saved connection.
For service principals, an administrator must enable the Allow service principals to use Power BI APIs tenant setting, and the service principal must be granted access to the target workspace and semantic model. Microsoft documents this requirement under the service principal limitations for Execute DAX Queries in Group.
For general connection form guidance, see Connect.
Features in DBCode
Section titled “Features in DBCode”- DAX execution: Run complete DAX queries against the selected semantic model.
- Multiple result sets: A query with multiple
EVALUATEstatements produces a separate DBCode result set for each returned Arrow stream. - Typed results: Power BI’s Apache Arrow response preserves numbers, dates, timestamps, booleans, strings, nulls, and other supported values for the DBCode results grid.
- Model browsing: Browse tables directly under the semantic model, then load columns, measures, and relationships progressively as you explore.
- Locked progressive introspection: The metadata loading strategy stays enabled so large models are not scanned eagerly.
- Hidden metadata: Hidden tables, columns, and measures remain visible and are marked as hidden. Hidden state is model presentation metadata, not a permission boundary.
- Data exploration: Preview table data and export query results.
The Execute DAX Queries in Group API supports one DAX query per request, with multiple EVALUATE statements in that query.
Query behavior
Section titled “Query behavior”DBCode sends the complete DAX selection to Power BI unchanged. It does not split queries on semicolons or blank lines because both can appear inside valid formatted DAX.
If a file contains several independent queries, select the query you want to run before executing it. A complete query can contain DEFINE, variables, comments, formatting, and multiple EVALUATE statements.
DEFINE MEASURE 'Sales'[Average Order Value] = DIVIDE([Total Sales], [Order Count])
EVALUATESUMMARIZECOLUMNS( 'Sales'[Region], "Average Order Value", [Average Order Value])Preview limitations
Section titled “Preview limitations”Power BI Semantic Models support is in Preview:
- Connections are read-only. DBCode does not create, update, refresh, or delete model objects or data.
- DAX and DAX
INFOfunctions are supported. SQL, MDX, DMV queries, and raw XMLA are not supported. My Workspaceis not included. Select a shared Power BI workspace.- The temporary Microsoft sign-in may identify the requesting application as Power BI PowerShell during consent. It is a Preview validation path and will be replaced with DBCode’s own Microsoft client registration.
- DAX autocomplete, formatting, and diagnostics are not available yet. DAX stays isolated from DBCode’s SQL parser so the editor does not apply incorrect SQL behavior.
- Cancelling a query stops DBCode’s request and local result processing. Power BI might continue the server-side work until it completes or reaches the configured query timeout.
Future XMLA, MDX, or DMV work can reuse the existing workspace to semantic model hierarchy without changing how connections and databases are mapped. This is an architectural path for future evaluation, not a commitment to add those features.
For more information about the API and its supported query types, permissions, and limitations, see Execute DAX Queries in Group.