[英]How to add filters before loading reports
I am new to power bi. 我是Power Bi的新手。
I have implemented multiple simple power bi reports where back-end is IMPORT not Direct Query and with Excel-sheet. 我已经实现了多个简单的Power Bi报告,其中后端是IMPORT而不是Direct Query,并且使用Excel工作表。
I have also embedded them successfully using power bi embedded and IFrame. 我还使用Power bi Embedded和IFrame成功地将它们嵌入。 Now I have a challenges: 现在我面临一个挑战:
I want to filter my reports by date range. 我想按日期范围过滤报告。
before loading report using power bi embedded or IFrame, I want to apply two filters fromdate and todate. 在使用Power Bi Embedded或IFrame加载报告之前,我要应用两个过滤器fromdate和todate。 these filters value will be chosen from web app datepicker, then on click of load, i want to show my report by applying these filters. 这些过滤器值将从Web应用程序的日期选择器中选择,然后单击加载,我想通过应用这些过滤器来显示我的报告。
I have gone through following links, but still not understanding how to implement this: 我已经通过以下链接,但仍然不了解如何实现此目的:
Power BI Embed URL-multiple filters Power BI嵌入URL多个过滤器
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details
Even i got the same requirement where we have embedded report and from client side we have date range picker. 甚至我在嵌入报表的地方也有相同的要求,而在客户端,我们有日期范围选择器。 Once you select date range then your report should filter. 选择日期范围后,您的报告将被过滤。 I tried to do it pushing dates manually and it worked, which is from javascript. 我尝试手动推送日期,并且有效,它来自javascript。 Below is the sample code 下面是示例代码
var fromDate = new Date("2011/10/30");
fromDate = fromDate.toJSON();
var toDate = new Date("2011/02/01");
toDate = toDate.toJSON();
$predefinedFilter1.on('click', function (event) {
var models = window['powerbi-client'].models;
const advancedFilter = new models.AdvancedFilter({
table: "Time",
column: "Date"
}, "And", [
{
operator: "GreaterThan",
value: fromDate
},
{
operator: "LessThan",
value: toDate
}
]);
//report.page("ReportSection3").setFilters([advancedFilter])
report.setFilters([advancedFilter])
.catch(errors => {
// Handle error
});
});
Hope you can understand this. 希望你能理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.