• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

226
Views
Filters in Power BI embed report

I developed a few months ago a NodeJS API to get embed reports from Power BI (using a tenant). I consume this API from an Angular app. Now I want to get the report filtered, and I don't know if this is possible with my actual code.

I used the PowerBI rest API to get the embed report. Reading the docs of microsoft, I see lots of docs like this one, where says that I should create an object with the filters that I want. This is not a problem, but I don't know if this is compatible with mi actual Node API or I should develop a new solution.

My API follows the sample provided by Microsoft, and the code is:

async function getEmbedParamsForSingleReport(
  workspaceId,
  reportId,
  additionalDatasetId
) {
  const reportInGroupApi = `https://api.powerbi.com/v1.0/myorg/groups/${workspaceId}/reports/${reportId}`;
  const headers = await getRequestHeader();
  // Get report info by calling the PowerBI REST API

  const result = await axios.get(reportInGroupApi, { headers });

  if (result.status !== 200) {
    throw result;
  }

  // Convert result in json to retrieve values
  const resultJson = result.data;

  // Add report data for embedding
  const reportDetails = new PowerBiReportDetails(
    resultJson.id,
    resultJson.name,
    resultJson.embedUrl
  );

  const reportEmbedConfig = new EmbedConfig();

  // Create mapping for report and Embed URL
  reportEmbedConfig.reportsDetail = [reportDetails];

  // Create list of datasets
  let datasetIds = [resultJson.datasetId];

  // Append additional dataset to the list to achieve dynamic binding later
  if (additionalDatasetId) {
    datasetIds.push(additionalDatasetId);
  }

  // Get Embed token multiple resources
  reportEmbedConfig.embedToken =
    await getEmbedTokenForSingleReportSingleWorkspace(
      reportId,
      datasetIds,
      workspaceId
    );
  return reportEmbedConfig;
}

With this I obtain the embed report and send back to my app. Is this solution compatible with filters?

Thanks in advance!

about 3 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Finally, I came out with a solution. In mi Angular app, I use the library powerbi-client-angular. That allows me to define some configuration in the embed report:

  basicFilter: models.IBasicFilter = {
    $schema: 'http://powerbi.com/product/schema#basic',
    target: {
      table: 'items',
      column: 'id',
    },
    operator: 'In',
    values: [1,2,3],
    filterType: models.FilterType.Basic,
    requireSingleSelection: true,
    displaySettings: {
      /** Hiding filter pane */
      isLockedInViewMode: true,
      isHiddenInViewMode: true,
    },
  };

  reportConfig: IReportEmbedConfiguration = {
    type: 'report',
    id: cuantitativeReportID,
    embedUrl: undefined,
    tokenType: models.TokenType.Embed,
    filters: [this.basicFilter],
    accessToken: undefined,
    settings: undefined,
  };

With this, I can avoid passing information to the NodeJS API

about 3 years ago · Juan Pablo Isaza Report

0

Yes, It will work fine with this solution. Please find the relevant code below:

  1. Create a filter object:
const filter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Geo",
column: "Region"
},
operator: "In",
values: ["West", "Central"]
};
  1. Add the filter to the report's filters:
await report.updateFilters(models.FiltersOperations.Add, [filter]);

You can refer sample NodeJS application to get embed reports from Power BI. Please find the the reference here: https://github.com/microsoft/PowerBI-Developer-Samples/tree/master/NodeJS

about 3 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error