1
votes

So I have the embed working in Power Bi based on this model

[https://community.powerbi.com/t5/Developer/Embedded-Report-add-filter-to-EmbedConfig/td-p/199739]

But things start failing once I add in the filter. Its throwing an error in including settings in the config. I'm following the model outlined in this post. Here is the error and code block it is throwing in Angular 4. Anyone have any thoughts as to what is going on this one?

ERROR in src/app/components/reporting/reporting.component.ts(73,49): error TS2345: Argument of type '{ type: string; accessToken: string; embedUrl: string; id: string; filters: { $schema: string; ta...' is not assignable to parameter of type 'IEmbedConfigurationBase | undefined'. Type '{ type: string; accessToken: string; embedUrl: string; id: string; filters: { $schema: string; ta...' is not assignable to type 'IEmbedConfigurationBase'. Types of property 'settings' are incompatible. Type '{ filterPaneEnabled: boolean; navContentPaneEnabled: boolean; }' is not assignable to type 'ISettings | undefined'. Type '{ filterPaneEnabled: boolean; navContentPaneEnabled: boolean; }' has no properties in common with type 'ISettings'.

    let accessToken = 'XXX';

        let embedUrl = 'https://app.powerbi.com/dashboardEmbed?dashboardId=XXX';

        let embedReportId = 'XXX';

        const myFilter = {
            $schema: "http://powerbi.com/product/schema#advanced",
            target: {
                table: "myTable",
                column: "myColumn"
            },
            operator: "In",
            values: ["1"]
        };

        let config= {
            type: 'dashboard',
            accessToken: accessToken,
            embedUrl: embedUrl,
            id: embedReportId,
            filters: [myFilter],
            settings: {
                filterPaneEnabled: true,
                navContentPaneEnabled: false
            }
        };

        // Grab the reference to the div HTML element that will host the report.
        let reportContainer = document.getElementById('reportContainer');

        // Embed the report and display it within the div container.
        let powerbi = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);
        let report = powerbi.embed(reportContainer, config);
2

2 Answers

1
votes

I had the same issue. Just replace local settings as follows.

        settings: {
      localeSettings: {
        language: "en",
        formatLocale: "es"
      }
    }
0
votes

I don't know if this is the cause for this, but it can cause some issues - you're mixing 2 methods.. Report Embedding supports filters in its config (IReportLoadConfig)[https://github.com/Microsoft/powerbi-models/blob/1daad509c435a6f722222d753f1372c80763ad33/src/models.ts#L618], which uses the interface you are referring to in myFilter...

However, you're trying to embed a dashboard, judging by your config type ('dashboard') & your embedUrl (dashboardEmbed). This might be an issue with typing.

In addition, I'd advise you to use the typings available in the Power BI JS SDK or in (PowerBI-Models)[https://github.com/Microsoft/powerbi-models/] to make sure you pass the types as needed, using the Typescript type-checking.