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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Filtering with Power BI Embedded

TL;DR: I get the error "Could not serialize filter. Could not retrieve filter values." when calling visual.getFilters() after setting a basic filter using visual.setFilters().

 

I am implementing a solution that takes the idea of the Quick visual creator sample and extending it futher to also include more visual types, extended data field application and filtering. This part of my application is called Quick Builder, so I will reference it using that name below.

 

I have been successful in loading different visual types, applying data fields to the different roles, retrieving the filters and setting empty filters. However, I am now attempting to set filter values and am unable to find a working solution.

 

As an example, I have saved a report via Power BI and set a filter. I load that saved report into my Quick Builder and get the filters via visual.getFilters() (where visual is a reference to a specific visual instance). When I receive the filter I saved, I see it as the following:

 

 

{
	"$schema": "http://powerbi.com/product/schema#basic",
	"target": {
		"table": "Organization",
		"hierarchy": "Organization Region",
		"hierarchyLevel": "Region",
		"keys": ["Region.Key0"]
	},
	"filterType": 1,
	"operator": "In",
	"values": ["FSC / Operations", "Southern Region"],
	"requireSingleSelection": false,
	"keyValues": [
		[605069053],
		[-1788494854]
	]
}

 

 

 

I then have UI components that allow the user to update the filter selection. I then attempt to call visual.setFilters() with different values. I construct the filter like the below snippet. 

 

 

filter = new models.BasicFilterWithKeys(...)
/* {
	"$schema": "http://powerbi.com/product/schema#basic",
	"target": {
		"table": "Organization",
		"hierarchy": "Organization Region",
		"hierarchyLevel": "Region",
		"keys": ["Region.Key0"]
	},
	"filterType": 1,
	"operator": "In",
	"values": ["Operations", "Northern Region"],
	"requireSingleSelection": false,
	"keyValues": [
		[-1079237640],
		[174253560]
	]
} */

visual.setFilters([filter]).then(...)
.catch(...)

 

 

 

The visual updates to reflect the filter applied correctly. However, every time I call visual.getFilters() after that, the promise resolves in error with the following:

 

 

visual.getFilters().then({...})
.catch(err => {...}) // err = {"message":"Could not serialize filter. Could not retrieve filter values."}

 

 

 

Getting this exception when attempting to get filters completely breaks the flow of my tool because when I load the report, I am unable to get the list of filters that I need to show to allow the user to interact with.

 

I have tracked this error down in the code to jsonfilter.js, line 722 where it checks for cachedValueItems when attempting to serialize a basic filter. Every time I set my own filter with values and set a breakpoint in the browser dev tools, this cachedValueItems value is undefined. When I set the filter without values (clearing the filter), the filter is successfully applied to the visual and the getFilters() function promise resolves successfully.

 

I specifically interact with filters on the one and only visual in the report, but the same issue exists when attempting to set page-level or report-level filters.

 

Can anyone help me understand what I need to do to get this working correctly? Is there some process I need to kick off or something to set cachedValueItems for a filter?

0 REPLIES 0

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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