Reputation: 1810
I have a Power BI report Embedded with some visuals. If we apply visual filter it is filtering all Visuals. What I want is if I select any particular Visual the filter applied for the Visual should be removed. How can I achieve that?
Upvotes: 0
Views: 1170
Reputation: 1810
Use dataSelected
event to select a particular visual. To remove filters from the selected visual, use updateFilters
. Here is the code:
// report.on will add an event listener.
report.on("dataSelected", function (event) {
const pages = await report.getPages();
// Retrieve the active page.
let page = pages.filter(function (page) {
return page.isActive
})[0];
const visuals = await page.getVisuals();
// Select the Visual
let data = event.detail;
// Retrieve the target visual.
let visual = visuals.filter(function (visual) {
return visual.name === data.visual.name;
})[0];
// Remove the filters applied to the visual
await visual.updateFilters(models.FiltersOperations.RemoveAll);
});
References:
Control Report Filter - Power BI Embedded
Upvotes: 1