Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Trying to update a power bi embedded visual filter

I am trying to update filters on single visuals that are embedded, but I can't seem to make it work.

 

I embed my visuals like this:

 

 

 

 

let embedConfiguration = {
                        accessToken: "@ViewBag.Token",
                        embedUrl: "@ViewBag.EmbedUrl",
                        id: "@ViewBag.Id",
                        pageName: pageName,
                        tokenType: 1,
                        type: 'visual',
                        visualName: visualName
                    };
                     
                    // Get a reference to the HTML element that contains the embedded report.
                    let embedContainer = $('#'+embedContainerName)[0];
                    let visual = powerbi.embed(embedContainer, embedConfiguration);
}

 

 

 

 

and this is working fine, I get my visuals up how I want them, but when I try to update the filters of them nothing happens. I have tried numerous ways from the powerbi embedded sandbox and microsoft.learn.

If I want to update the filters, shouldnt it be as easy as to do following?: 

 

 

 

 

const filter = {
                    $schema: "http://powerbi.com/product/schema#basic",
                    target: {
                        table: "Personskader",
                        column: "Disiplin"
                    },
                    operator: "In",
                    values: ["Insulation"]
                };
                
                // Add the filter to the report's filters.
                try {
                    
                    await visual.updateFilters(models.FiltersOperations.Add, [filter], models.FiltersLevel.visual);
                    console.log("Report filter was added.");
                }
                catch (errors) {
                    console.log(errors);
                }

 

 

I tried adding the above code underneath the powerbi.embed(embedContainer, embedConfiguration);

Is there a way to get the single embedded visual?

If I try:

let visual = document.getElementById("embedContainer");
visual.updateFilters.....

 It won't find the function updateFilters. 

 

Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

We can Apply Visual level filters to every Visual. You can use updateFilters to set new filter to the Visual our Update the filters.
Simply add this piece of code On the js for embedding in the display each Visual section or you use the variable visualName and apply filters later to the visual.

await visualName.updateFilters(models.FiltersOperations.Replace, filtersArray);

For reference: Visual level filters

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

We can Apply Visual level filters to every Visual. You can use updateFilters to set new filter to the Visual our Update the filters.
Simply add this piece of code On the js for embedding in the display each Visual section or you use the variable visualName and apply filters later to the visual.

await visualName.updateFilters(models.FiltersOperations.Replace, filtersArray);

For reference: Visual level filters

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.