Forum Discussion
Anonymous
8 years agoNot applicable
Power BI Embedded - Filters
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 S...
Anonymous
8 years agoNot applicable
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
v-jiascu-msft
8 years agoMicrosoft Employee
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
- Anonymous8 years agoNot applicable