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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

Set filters while embedding a visual

Hello everyone, 

I am trying to set the filters on the visual while embedding it. 
I am getting the following error. 
error.png

Is there any workaround for this? 

 

The embed code:

	const filter = {
		$schema: "http://powerbi.com/product/schema#basic",
		target: {
			table: "Manufacturer",
			column: "Sample Data"
			},
		operator: "In",
		values: ["Abbas"]
	};

    var config = {
        type: 'visual',
        accessToken: accessTokenToUse,
        embedUrl: embedURLToUse,
        reportId: reportIdToUse,
        pageName: pageNameToUse,
        visualName: visualNameToUse		
     };	
    var dashboard = powerbi.embed(visualDiv, config);
	dashboard.setFilters([filter]);  



1 ACCEPTED SOLUTION
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

I'm afraid setting filters while embedding visuals isn't available for now. Please refer to the source code of Powerbi.js. I would suggest you create an idea here.

 

Set_filters_while_embedding_a_visual

 

Best Regards,

Dale

Community Support Team _ Dale
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

2 REPLIES 2
artemmuntianu
Frequent Visitor

Hi

Recently I have come across that problem as well

Just found a solution. It is to change object <filters> and call method <reload> of Visual.

 

/**
         * Reloads embed using existing configuration.
         * E.g. For reports this effectively clears all filters and makes the first page active which simulates resetting a report back to loaded state.
         *
         * ```javascript
         * report.reload();
         * ```
         */
        reload(): Promise<void>;

 

For example

const pbiService = new pbi.service.Service(pbi.factories.hpmFactory, pbi.factories.wpmpFactory, pbi.factories.routerFactory);
const embeddedObj = <pbi.Visual>(pbiService.embed(embedContainer, embedObj.config as {}));
// will update visual using new filters from newFiltersArr after 10 seconds
setTimeout(() => {
    (embeddedObj.config as any).filters = newFiltersArr;
    embeddedObj.reload();
}, 10000);

 

v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

I'm afraid setting filters while embedding visuals isn't available for now. Please refer to the source code of Powerbi.js. I would suggest you create an idea here.

 

Set_filters_while_embedding_a_visual

 

Best Regards,

Dale

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

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.