如何在报告中设置过滤器 Power BI 嵌入式 javascript

编程入门 行业动态 更新时间:2024-10-24 00:26:01
本文介绍了如何在报告中设置过滤器 Power BI 嵌入式 javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在我的报告 power bi 嵌入式上添加一些过滤器,我有一个 html 文件,我需要在 javascript 中添加一些过滤器,但我没有开发经验.我只需要看一个例子就知道如何添加它.

I want to add somes filters on my reports power bi embedded, i have an html file, and i need to add somes filters in javascript but i dont have experience as a developer. I just need to see an exemple to see how to add it.

<head> `enter code here` <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>test</title> <script type="text/javascript" language="javascript" src="code.jquery/jquery-1.12.4.js"></script> <script type="text/javascript" language="javascript" src="rawgit/Microsoft/PowerBI-JavaScript/master/dist/powerbi.min.js"></script> </head> <body> <h1>test</h1> <div id="reportContainer" style="width: 80%; height: 800px;"></div> </body> <script> $(document).ready(function () { var getEmbedToken = "testclienttest.azurewebsites/api/HttpTrigger1?code=XXXXXXXXXXXXXXXXXXX/XXXXXXXXXXXXX=="; $.ajax({ url: getEmbedToken, jsonpCallback: 'callback', contentType: 'application/javascript', dataType: "jsonp", success: function (json) { var models = window['powerbi-client'].models; var embedConfiguration = { type: 'report', id: json.ReportId, embedUrl: json.EmbedUrl, tokenType: models.TokenType.Embed, accessToken: json.EmbedToken }; var $reportContainer = $('#reportContainer'); var report = powerbi.embed($reportContainer.get(0), embedConfiguration); }, error: function () { alert("Error"); } }); }); </script> </html>

我认为要添加的过滤器在此行之后:var report = powerbi.embed($reportContainer.get(0), embedConfiguration);

i think the filters to add is after this line : var report = powerbi.embed($reportContainer.get(0), embedConfiguration);

推荐答案

要过滤您的嵌入报告,您必须构造一个或多个过滤器并将它们作为数组传递给 JavaScript 客户端 - 在 filters 中embedConfiguration 的属性,或作为 report/page/visual setFilters 的参数方法.

To filter your embed report, you must construct one or more filters and pass them as array to the JavaScript client - either in filters property of embedConfiguration, or as a parameter to report/page/visual setFilters method.

过滤器可以是以下类型之一:

The filters can be from one of these types:

  • IBasicFilter
  • 高级过滤器
  • IRelativeDateFilter
  • ITTopNFilter
  • IIncludeExcludeFilter

例如,过滤名为 Product 的表以仅显示数据,其中 Count 列为 1、2 或 3,可以如下构造:

For example, to filter table named Product to show only data, where Count column is 1, 2 or 3 can be constructed as follows:

const basicFilter: pbi.models.IBasicFilter = { $schema: "powerbi/product/schema#basic", target: { table: "Product", column: "Count" }, operator: "In", values: [1,2,3], filterType: 1 // pbi.models.FilterType.BasicFilter }

然后修改您的代码以将此过滤器传递给 embedConfiguration:

Then modify your code to pass this filter to embedConfiguration:

var embedConfiguration = { type: 'report', id: json.ReportId, embedUrl: json.EmbedUrl, tokenType: models.TokenType.Embed, accessToken: json.EmbedToken, filters: [basicFilter] };

有关配置嵌入元素的详细信息,请参阅 嵌入配置详细信息 并查看有关如何使用不同过滤器类型和应用它们的更多信息,请参阅 过滤器.

For more information about configuring the embed element, see Embed Configuration Details and to see more information on how to use different filter types and applying them, see Filters.

更多推荐

如何在报告中设置过滤器 Power BI 嵌入式 javascript

本文发布于:2023-10-30 11:52:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1542776.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:过滤器   嵌入式   报告   如何在   Power

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!