Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello All,
Greetings, I had been created an Alert Data report with two parameters such as Start Date and End Date, the scenario of the report is that the user will first select the Start Date and End Date, and according to that date range the report will be displayed for that particular data. The report was working fine and I had published it to the Power BI Service too and there also the parameters are perfectly working.
const filter1 = { $schema: "http://powerbi.com/product/schema#advanced", target: { table: "Alert", column: "Date" }, logicalOperator: "And", conditions: [ { operator: "GreaterThanOrEqual", value: sd }, { operator: "LessThanOrEqual", value: ed } ], }; var reportContainer = $('#reportContainer')[0]; var report = powerbi.embed(reportContainer, config); //report.on('loaded', event => { report.getFilters().then(filters => { filters.push(filter1); return report.setFilters(filters); }) }); report.setFilters([filter1]);
Hi,
I implemented Embedded-filter in my reports too. but it is not working since today morning. I went to the demo site but it is also not working here, Please update us if Microsoft is making some changes in embedded filter option.
https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#
regards
Deepak Kumar Mishra
deepak@gs1india.org
Any solutions to this question...
Regards,
Geetha
Hi @Anonymous,
I would suggest you try the online demo here. You also can download the source code. It could be like below.
// Build the filter you want to use. For more information, See Constructing // Filters in https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters. const filter = { $schema: "http://powerbi.com/product/schema#basic", target: { table: "Store", column: "Chain" }, operator: "In", values: ["Fashions Direct"] }; // Get a reference to the embedded report HTML element var embedContainer = $('#embedContainer')[0]; // Get a reference to the embedded report. report = powerbi.get(embedContainer); // Retrieve the page collection and get the visuals for the first page. report.getPages() .then(function (pages) { // Retrieve active page. var activePage = pages.find(function(page) { return page.isActive }); activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. var visual = visuals.find(function(visual) { return visual.name == "VisualContainer3"; }); // Set the filter for the visual. // Pay attention that setFilters receives an array. visual.setFilters([filter]) .catch(function (errors) { Log.log(errors); }); }) .catch(function (errors) { Log.log(errors); }); }) .catch(function (errors) { Log.log(errors); });
Best Regards,
Dale
Hai @v-jiascu-msft thank you for your response, I had already tried the online demo but yet I couldn't able to find the bug.
Kind Regards,
Geetha
Hi Geetha,
What is the type of the filter? If it's a visual level filter, we should get the report first and then get the page and the visual. At last we can set the filter.
// Build the filter you want to use. For more information, See Constructing // Filters in https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters. const filter = { $schema: "http://powerbi.com/product/schema#basic", target: { table: "Store", column: "Chain" }, operator: "In", values: ["Fashions Direct"] }; // Get a reference to the embedded report HTML element var embedContainer = $('#embedContainer')[0]; // Get a reference to the embedded report. report = powerbi.get(embedContainer); // Retrieve the page collection and get the visuals for the first page. report.getPages() .then(function (pages) { // Retrieve active page. var activePage = pages.find(function(page) { return page.isActive }); activePage.getVisuals() .then(function (visuals) { // Retrieve the wanted visual. var visual = visuals.find(function(visual) { return visual.name == "VisualContainer3"; }); // Set the filter for the visual. // Pay attention that setFilters receives an array. visual.setFilters([filter]) .catch(function (errors) { Log.log(errors); }); }) .catch(function (errors) { Log.log(errors); }); }) .catch(function (errors) { Log.log(errors); });
Best Regards,
Dale
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
16 | |
2 | |
2 | |
1 | |
1 |
User | Count |
---|---|
13 | |
6 | |
4 | |
3 | |
2 |