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

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

问题描述

我的问题是参考以下文档,该文档是 Power BI Embedded Query Parameters API 的一部分,位于 https://azure.microsoft.com/en-us/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天全站免登陆