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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
shivprasads
Frequent Visitor

Adding Custom Filter to Embed report

I am working on a demo project which uses the powerbi.js file to embed the report.

 

var reportConfig = {
                settings: {
                    filterPaneEnabled: true
                }                
            };

var report = powerbi.embed(reportElement, reportConfig);

 

 

I am trying to create a filter object and set it to the reportConfig's property so the report gets loaded along with the filter.

Below is the basic filter I am creating.

 

 var basicFilterdemo = {
                $schema: "http://powerbi.com/product/schema#basic",
                target: {
                    table: "Query1",
                    column: "Email"
                },
                operator: 'In',
                values: ['test@gmail.com']
            };

 

Can some one help me get a way to configure the filter. 

setting 

var reportConfig = {
                settings: {
                    filterPaneEnabled: true
                },
basicFilter:basicFilterdemo };

 

dint work and also how do I set the level(Report/Page) at which this filter would be set.

 

calling addFilter() inside report.on('loaded',function() works fine but the original report is first loaded and stays there for a couple of seconds and then the change occurs. So that isnt a viable option for me

 

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@shivprasads

 

You can create a filter and apply it to the filters properties of the embed configuration. Check Embed Configuration Details.
The problem now is, there's a bug that stops the filters properties from working, check validateReportLoad incorrectly returns schema errors for valid filters. The workaround is, as your mentioned, set the filter after loaded.

Regarding how to set the level(Report/Page), check Understanding the object hierarchy, Both Report and Page have the setfilters function. 

 

View solution in original post

4 REPLIES 4
phaneendhrav
Regular Visitor

@shivprasads:

 

I'm also facing similar issue. Did you get the solution?

@phaneendhrav

No I wasnt able to reach at a viable solution at the time last tested.

 

As per their response,

"The problem now is, there's a bug that stops the filters properties from working, check validateReportLoad incorrectly returns schema errors for valid filters. The workaround is, as your mentioned, set the filter after loaded"

 

The bug could have been fixed.

But if you are implementing it correctly and yet not able to get the filter in place, then lets conclude the bug still exists.

 

You might want to try the workaround I tried mentioned in my query itself, although it wasnt a viable solution for me

Eric_Zhang
Employee
Employee

@shivprasads

 

You can create a filter and apply it to the filters properties of the embed configuration. Check Embed Configuration Details.
The problem now is, there's a bug that stops the filters properties from working, check validateReportLoad incorrectly returns schema errors for valid filters. The workaround is, as your mentioned, set the filter after loaded.

Regarding how to set the level(Report/Page), check Understanding the object hierarchy, Both Report and Page have the setfilters function. 

 

So you mean the entire filter property isnt working for now when setting it up in the embed configuration.

And the way I have done with the function being called at the load event is the way we need to do, at least for now?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Kudoed Authors