Bind datasets dynamically to a report

Power BI reports are built based on an existing dataset. That dataset defines the data schema that the report visuals use. By using dynamic binding, you can select a dataset on the fly when you embed a report.

The datasets that you select need to use the same data schema. But if you have multiple datasets with the same data schema, your report can connect, or bind, dynamically to each of those datasets. You can then display different insights, depending on your needs.

Dynamic binding offers other advantages, too. You don't need to create a copy of the same report with a different dataset for each user. One report can serve multiple users. This feature then reduces the number of maintained artifacts and improves the application life cycle handling. As a result, dynamic binding simplifies onboarding for new customers.

How to connect a report to multiple datasets dynamically

You can store reports and datasets in separate workspaces. However, both workspaces must be new workspaces, rather than classic workspaces, and both workspaces should have a capacity.

When embedding for customers, the embed token must include permissions for both the report and the dynamically bound dataset. Use the new API to generate an embed token which supports Power BI items, such as reports and dashboards.

When embedding for your organization, the user's Azure Active Directory (AD) token that you use must have appropriate permissions for all Power BI items.

Example

To implement an embedded solution using dynamic binding, add the datasetBinding property to the embed configuration object, as shown in the following example.

let config = {
    type: 'report',
    tokenType: models.TokenType.Embed,
    accessToken: accessToken, // The access token should have permissions for all artifacts.
    embedUrl: embedUrl,
    id: "reportId", // The id of the report that you want to embed
    permissions: permissions,
    datasetBinding: {
        datasetId: "notOriginalDatasetId", // The dataset id that you want the report to use 
    }
};

// Get a reference to the embedded report HTML element.
let embedContainer = $('#embedContainer')[0];

// Embed the report and display it within the div container.
let report = powerbi.embed(embedContainer, config);

Limitations

  • The dynamically selected dataset must use the same data schema in the report.
  • When embedding for customers, generate an embed token using the new API.
  • When embedding for your organization, ensure the user has permissions for both the report and dataset.
  • Only the new workspaces are supported, not the classic workspaces. The report and datasets must be inside a new workspace.

Next steps