Can I pass a dynamic query parameter to an embedded Power BI report in ASP.Net MVC?

后端 未结 1 1138
被撕碎了的回忆
被撕碎了的回忆 2021-01-03 15:58

My question is in reference to the following documentation that is part of Power BI Embedded Query Parameters API at https://azure.microsoft.com/en-us/updates/power-bi-embed

1条回答
  •  一生所求
    2021-01-03 16:39

    Parameters aren't good choice in this case. Using the API you can change their values, but these values are stored in the report itself and all users, who opens these reports, will be affected by the parameter value changes.

    You should use filters to achieve that. Let's say you have a table named SchoolData in your model, and a column named SchoolId in it. When you embed the report in your application, define a filter for this column, e.g. like this:

    const basicFilter = {
        $schema: "http://powerbi.com/product/schema#basic",
        target: {
            table: "SchoolData",
            column: "SchoolId"
        },
        operator: "In",
        values: [1],
        filterType: models.FilterType.BasicFilter
    }
    

    And then pass this filter in embed configuration details:

    var config = {
        type: embedType,
        accessToken: accessToken,
        tokenType: tokenType,
        embedUrl: embedUrl,
        id: embedId,
        dashboardId: dashboardId,
        permissions: permissions,
        filters: [basicFilter],
        settings: {
            filterPaneEnabled: true,
            navContentPaneEnabled: true
        }
    };
    

    where 1 is the value corresponding to the currently logged user. Change it every time, when the report is shown in your application, depending on the current user (i.e. 2, 3, 4, etc.).

    More information on how to filter data with Power BI Embedded can be found in Filters documentation.

    0 讨论(0)
提交回复
热议问题