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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
sami_romdhana
New Member

Power BI Embed - Getting filters of particular visual is impossible

Hello.

We have an utility that gets all the filter information of every visual using the standard #getFilters method. For some reason, we can't get the filters of one visual.

 

The filters applied to this visual have empty values (one advanced filter, one Top N filter) which hasn't been a problem on other visuals. No filter displays the warning icon that a filter is invalid.

When trying to track down the problem, we could reproduce it using the playground and this snippet of code:

try {
    const pages = await report.getPages();
    const page = pages.find(page => page.isActive);
    const visuals = await page.getVisuals();
    const visual = visuals.find(visual => visual.name === "<visual ID>");

    console.log(await visual.getFilters());
}
catch (errors) {
    console.log("Error", errors);
}

However, the error is just undefined.

When trying to debug further into Microsoft's code, it seems that there is an actual error but that it is mishandled, here is the stack:

{ "message": "Invoked filter serialization function with no filter.", "stack": "Error: Invoked filter serialization function with no filter. at De.ensureError (https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.min.b01b01905167f493a762.js:1:1458833) at De.throwException (https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.min.b01b01905167f493a762.js:1:1460336) at i.serializeFilter (https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.json-contracts.min.4dbb3fc597b1e8406319.js:1:7900) at I.fromSemanticFilter (https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.json-contracts.min.4dbb3fc597b1e8406319.js:1:6862) at https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.json-contracts.min.4dbb3fc597b1e8406319.js:1:29982 at Array.map (<anonymous>) at u.tryGetFilters (https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.json-contracts.min.4dbb3fc597b1e8406319.js:1:29970) at https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.filter.min.902d70a4ede44353ca9e.js:1:2916 at Generator.next (<anonymous>) at n (https://content.powerapps.com/resource/powerbiwfe/scripts/reportEmbed.vendors.min.b4e0d0f6f68362882eed.js:1:789804)" }

And this ends up being unused as the #getFilters method tries to get a body even when it isn't set, as can be seen here: https://github.com/microsoft/PowerBI-JavaScript/blob/master/src/visualDescriptor.ts#L108

 

So it seems that:
* There is a particular problem when serializing some filters

* When that happens we can't get an accurate error

Is there any possibility of at least seeing issue #1 fixed? We can provide a sample using email if necessary (sample has private data).

Thanks

1 REPLY 1
Nasif_Azam
Impactful Individual
Impactful Individual

Hey @sami_romdhana ,

You're hitting a known issue with the Power BI JavaScript SDK's getFilters() method when it tries to serialize certain filter types like Top N or Advanced filters with missing or undefined values.  The internal method serializeFilter() throws:  Error: Invoked filter serialization function with no filter.

This happens because some visuals contain a filter object with an undefined body, yet the SDK still attempts to serialize it and fails silently. Instead of catching and surfacing this error, the SDK mishandles it and returns undefined, which makes debugging almost impossible from the outside.

 

Workaround-1: Filter Out Problematic Visuals

Before calling getFilters(), you could do a check for visuals using getFilters() inside a try-catch and skip if it returns undefined or logs that serialization issue.

try {
    const filters = await visual.getFilters();
    if (!filters || filters.length === 0) {
        console.warn(`No filters found or failed for visual: ${visual.name}`);
    } else {
        console.log(filters);
    }
} catch (e) {
    console.error(`Error retrieving filters for visual ${visual.name}`, e);
}

This helps isolate the offending visual and possibly avoids full script breakage.

 

Workaround-2: Use report.getFilters() (page/report level)

This won’t give visual-level granularity but may capture filters that failed serialization on visuals.

const pageFilters = await page.getFilters();
const reportFilters = await report.getFilters();

This way, you may at least infer what’s being filtered and whether it's likely a Top N/advanced filter scenario.

 

Workaround-3: Rebuild the Filter in the Report UI

If you're able to modify the report:

  • Clear and recreate the problematic filter in Power BI Desktop.

  • Avoid incomplete Top N filters (e.g., without a full value definition).

  • Re-upload and test.

 

Workaround-4: Suggested Fix for Microsoft

You're right the fix ideally belongs in PowerBI-JavaScript GitHub: visualDescriptor.ts#L108. There should be a:

if (!filter) {
    return []; // Or log detailed error
}

 

For Detailed Information:
https://github.com/microsoft/PowerBI-JavaScript/blob/master/src/visualDescriptor.ts#L108
https://github.com/microsoft/PowerBI-JavaScript

https://learn.microsoft.com/javascript/api/overview/powerbi/visualdescriptor#getfilters
https://learn.microsoft.com/power-bi/developer/embedded/embed-sample-for-your-organization

https://github.com/microsoft/PowerBI-JavaScript/issues/new/choose

 

 

 

If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


Best Regards,
Nasif Azam

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.