Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 17893

Embedded Report add filter to EmbedConfig

$
0
0

Hey guys, so I am have a fully functioning embedded sample working but I am trying to make a small modification to the way the filter is applied in the JS.

 

Currently my code configures and embeds the report and then applies the filter after the fact.  I would like to add the filter to the config directly rather than applying it after the fact.  For example, here is my currently working code that applies a filter:

    const filter = {
        $schema: "http://powerbi.com/product/schema#advanced",
        target: {
            table: "table name",
            column: "column1"
        },
        operator: "In",
        values: ["SomefilterValue"]
    };

 var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId,
        permissions: models.Permissions.Read,
        settings: {
            filterPaneEnabled: true,
            navContentPaneEnabled: false
        }
    };

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

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

//Add filter to the reportreport.on('loaded', event => { report.getFilters() .then(filters => { filters.push(filter); return report.setFilters(filters); }); });

I saw on Embed configuration details that it's possible to add the filter directly to the embed configs.  I altered the embed configuration settings to include a filter and then removed the bolded report.on portion from the above code and now the filter is not being applied.

 

    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId,
        permissions: models.Permissions.Read,
        settings: {
            filterPaneEnabled: true,
            navContentPaneEnabled: false, filter: [filter]
        }
    };

Any ideas on how to properly add this filter in the settings of the config?


Viewing all articles
Browse latest Browse all 17893

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>