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

I keep getting an error telling me "filters property is invalid" in embed configuration in VS

$
0
0

Here's all the javascript:

 

    // Read embed application token from Model
    var accessToken = "@Model.EmbedToken.Token";

    // Read embed URL from Model
    var embedUrl = "@Html.Raw(Model.EmbedUrl)";

    // Read report Id from Model
    var embedReportId = "@Model.Id";

    // Get models. models contains enums that can be used.
    var models = window['powerbi-client'].models;

    // Set up filter for Response ID
    const filter = {
        $schema: "http://powerbi.com/product/schema#basic",
        target: {
            table: "ResponsesResultsUsers",
            column: "Response ID"
        },
        operator: "In",
        values: 26
    }
    // Embed configuration used to describe the what and how to embed.
    // This object is used when calling powerbi.embed.
    // This also includes settings and options such as filters.
    // You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
    var config = {
        type: 'report',
        tokenType: models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId,
        permissions: models.Permissions.All,
        filters: [filter],
        settings: {
            filterPaneEnabled: true,
            navContentPaneEnabled: false
        }
    };

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

    if ("@Model.Username" != "") {
        $("#RLS").prop('checked', true);
        $("#RLSdiv").show();
    }
    else
    {
        $("#RLS").prop('checked', false);
        $("#RLSdiv").hide();
    }

    if ("@Model.IsEffectiveIdentityRequired.GetValueOrDefault()" == "True") {
        $("#noRLSdiv").hide();
        $("#RLS").removeAttr("disabled");
        $("#RLS").change(function () {
            if ($(this).is(":checked")) {
                $("#RLSdiv").show(300);
            } else {
                $("#RLSdiv").hide(200);
            }
        });
    }
    else
    {
        $("#noRLSdiv").show();
    }
    // Embed the report and display it within the div container.
    var report = powerbi.embed(reportContainer, config);

    report = powerbi.get(reportContainer);

    // Set the filter for the report.
    // Pay attention that setFilters receives an array.
    report.setFilters([filter])
        .catch(function (errors) {
            Log.log(errors);
        });

It doesn't seem to recognize the "filters" property of the config object. The post-load application of the filter doesn't do anything either (if I comment out the "filters" property, then the report loads fine, but using the original value for "Response ID" not the one included in the "filter" contant declaration above.

 

It almost seems as though the filter support isn't included here. Could it be the use of powerbi-client vs. powerbi-models? the latter of which is referenced in the embedded filtering docs page.


Viewing all articles
Browse latest Browse all 17907

Trending Articles