我可以将动态查询参数传递给ASP.Net MVC中的嵌入式Power BI报表吗? [英] Can I pass a dynamic query parameter to an embedded Power BI report in ASP.Net MVC?

查看:209
本文介绍了我可以将动态查询参数传递给ASP.Net MVC中的嵌入式Power BI报表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是参考以下文档,该文档是Power BI嵌入式查询参数API的一部分,位于 https://azure.microsoft.com/zh-cn/updates/power-bi-embedded-query-parameters-api/

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-embedded-query-parameters-api/

请注意,参数是基于数据集的,因此它们是按报告/仪表板定义的,而不是基于用户的会话级别定义的.这意味着,同时使用同一报告的不同用户将始终看到相同参数的值."

"Note that the parameters are based on the dataset, so they are defined per report/dashboard, but not on the user’s session level. It means that different users who are using the same report at the same time will always see the same parameter’s value."

我们计划将使用Power BI创建的仪表板嵌入到.Net MVC应用程序中.许多学校用户(组织外部和不同学校的用户)将登录以访问这些报告.

We are planning to Embed dashboards created using Power BI into our .Net MVC application. A lot of school users(external to the organization and from different schools) would be logging in to access these reports.

让我们假设来自5个不同学校的5个用户试图访问仪表板,该仪表板已参数化以显示其学校的数据.我可以使用Power BI Embedded实现吗?我感到困惑的原因在于,文档指出,同时使用同一份报告的不同用户将始终看到相同参数的值.

Let us assume that 5 users from 5 different schools are trying to access a dashboard that is parameterized to display data as per their school. Can I achieve this using power BI Embedded? The source of my confusion is that the documentation states that different users who are using the same report at the same time will always see the same parameter’s value.

推荐答案

在这种情况下,参数不是很好的选择.使用API​​可以更改其值,但是这些值存储在报表本身中,所有打开这些报表的用户都将受到参数值更改的影响.

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.

您应该使用过滤器来实现.假设您的模型中有一个名为SchoolData的表,其中有一个名为SchoolId的列.将报表嵌入到应用程序中时,请为此列定义一个过滤器,例如像这样:

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
    }
};

其中,1是与当前登录的用户相对应的值.每次在报告显示在您的应用程序中时,都要进行更改,具体取决于当前用户(即2、3、4等).

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.).

有关如何使用Power BI Embedded过滤数据的更多信息,请参见过滤器文档.

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

这篇关于我可以将动态查询参数传递给ASP.Net MVC中的嵌入式Power BI报表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆