← Power BI integration

Querying Power BI datasets

A Power BI semantic model (the API still calls it a dataset) is a set of tables, relationships and measures that reports are built on. Daslab can query one directly with DAX, which means you can ask a question of the model without opening a report — and without anyone building a visual for it first.

Describe before you query

Call powerbi_describe_dataset before writing DAX against a model you haven't queried yet. It returns the tables, columns and measures, so the query you write refers to things that exist.

Skipping this is the most common way to waste a turn: a DAX query against a guessed column name fails with a parse error that looks like a syntax problem rather than a naming one.

Measures matter more than they look. A model with a Total Sales measure has already encoded how sales are supposed to be summed — currency conversion, returns, whatever the business decided. Re-deriving it with SUM(Sales[Amount]) will often produce a different and wrong number. Prefer the measure.

Writing the query

Every query must start with EVALUATE and return a table.

EVALUATE
TOPN(
  100,
  SUMMARIZECOLUMNS(
    'Date'[Year],
    'Product'[Category],
    "Revenue", [Total Sales]
  ),
  [Revenue], DESC
)

Aggregate in the query rather than pulling rows and summarizing afterwards. The service caps result size, and a bare EVALUATE 'Sales' against a real fact table will hit that cap and return a truncated answer that looks complete. SUMMARIZECOLUMNS with a TOPN around it is the shape that works.

One query per call. Semicolon-separated statements aren't supported.

Finding the dataset

powerbi_list_datasets lists models in a workspace. Omit workspace_id and it reads My workspace — the connected user's personal area — instead of a shared workspace. The same is true of powerbi_list_reports, powerbi_list_dashboards and the query tools.

Reports and datasets are different objects. powerbi_list_reports gives you a report and its datasetId; the queryable thing is the dataset. Two reports often sit on one model.

Two failures that aren't your query

UserNotLicensed. The connected account has no Power BI license. Power BI reports this as a 404 with an empty body on every endpoint, which reads exactly like a wrong URL — the diagnosis arrives only in a response header, which the error message surfaces for you. The fix is a Pro or PPU license, or a Fabric capacity, assigned to the connecting user. Nothing about the connection is wrong.

DAX fails while everything else works. Listing workspaces and reports succeeds, but powerbi_query returns an authorization error. That's the Dataset Execute Queries REST API tenant setting, which is separate from consent and often restricted to a security group. A Power BI administrator flips it in Admin portal → Tenant settings → Integration settings.

An empty workspace list with no error usually means the account is licensed but genuinely has no shared workspaces — content in My workspace doesn't appear under powerbi_list_workspaces.

Read-only

Every Power BI tool is read-only. Daslab requests Workspace.Read.All, Dataset.Read.All, Report.Read.All and Dashboard.Read.All, all delegated and all bounded by what the connected user can already see. Tenant.Read.All — the read-every-workspace-in-the-organization permission — is deliberately not requested, so a workspace the user can't open is invisible to the agent too.

DAX evaluation doesn't change the model. It reads.