Janhavi Satpute
Janhavi Satpute

Reputation: 11

Remove specific visual filter from report

I have a report with 10 visuals . How can I remove filter from the selected visual? If I select any one of the visual then it's applied filter should be removed.

Upvotes: 1

Views: 4640

Answers (2)

Rohit Ronte
Rohit Ronte

Reputation: 129

To remove the filters from the selected visual, you can use updateFilters and to get the details of the selected visual, you can use dataSelected event. Please find the below relevant code snippet:

Call dataSelected event:

report.on("dataSelected",async 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();

    // Retrieve the event details
    let data = event.detail;

    // Retrieve the target visual.
    let visual = visuals.filter(function (visual) {
        return visual.name === data.visual.name;
    })[0];
        
        // Remove the filers applied to the visual
    await visual.updateFilters(models.FiltersOperations.RemoveAll);
});

Please find the references: https://learn.microsoft.com/javascript/api/overview/powerbi/handle-events#dataselected
https://learn.microsoft.com/javascript/api/overview/powerbi/control-report-filters#filters-operation

Upvotes: 0

mkRabbani
mkRabbani

Reputation: 16908

If I get your issue correct, you are basically looking for disable interaction between visuals. Like, if you select country = A from visual 1, you still wants all country list in visual 2. If this is correct, follow this below steps-

Step-1: Select visual 1 and go to format tab from the ribbon and the edit interaction option as shown below-

enter image description here

Step-2: Now you can control your visual 2 should interact with visual 1 or not selecting either filter or none option as shown below. select None in visual 2 and it will give your expected output-

enter image description here

Upvotes: 0

Related Questions