Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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?
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 3 |