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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
chotu27
Post Patron
Post Patron

Power BI Embeded sample code for setting default filter

Hi,

 

How to set default filter in Power bi embed please share sample code it is critical for our project

2 REPLIES 2
chotu27
Post Patron
Post Patron

Hi,

I am using Power BI Embedding to display the Power BI Dashboard into my portal, All are working fine what is my workspace able to see the dashboard with 10 record in my web page. But when I try to filter 1 reocrd using Javascript, I see that the dashboard show all the 10 reccord for a second and then filter to show the 1 record based on the filter, In this case I see something like twice the dashoard is getting loaded (flickering), My need is that when I pass the filter in Configration poperty the dashboard should show only 1 record which means the filter should be applied at server side not on the client side. Can anyone please suggest  a solution for this 

 

 

 

            Sample Code :

var studyIdFilter = {

                $schema: "http://powerbi.com/product/schema#basic",

                target: {

                    table: "view_studyparameter",

                    column: "virgilstudyid"

                },

                operator: "In",

                values: ["2C2B6836-BE9B-4501-B415-011BAB91141A"]

            };

            var filter = [studyIdFilter];

 

            var config= {

                type: 'report',

                accessToken: accessToken,

                embedUrl: embedUrl,

                id: reportId,

                settings: {

                    filterPaneEnabled: true,

                    navContentPaneEnabled: true

                }

                ,

                filters: filter

             

              

            };

 

            // Grab the reference to the div HTML element that will host the report.

            var reportContainer = document.getElementById('reportContainer');

 

 

            // Embed the report and display it within the div container.

            var report = powerbi.embed(reportContainer, config);

 

 

Note : Please help us we are going live with Power bi embeded in 3 days it is critical 

 

 

Hi @chotu27,

But when I try to filter 1 reocrd using Javascript, I see that the dashboard show all the 10 reccord for a second and then filter to show the 1 record based on the filter, In this case I see something like twice the dashoard is getting loaded (flickering),

It seems to me that it could be the default behavior of the current API. And I don't think there is an option to change it currently. So I would suggest create a new issue on https://github.com/Microsoft/PowerBI-JavaScript/issues to see if the PG has a possible solution, or fix it in future. Smiley Happy

 

Regards

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.