António
António

Reputation: 975

PowerBI Javascript - Set page filters without set report filter first

Since last week when I try to apply a page filter without first setting the report filter I get an error on the console: Unhandled Promise rejection: Failed to execute 'postMessage' on 'Window': TypeError: Cannot read property 'instanceOfIVisualLevel' of undefined could not be cloned...

Using the demo it's possible to test this: https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#

  1. Sample Report
  2. Click "Run"
  3. Click "Interact"
  4. Go to "Filters & Slicers" and click "Set page filters"
  5. Click run to apply the page filter
  6. Check browser console

What is the problem? Is it missing something in the demo?

Upvotes: 1

Views: 1632

Answers (1)

James Webster
James Webster

Reputation: 4114

It turns out that this is a problem with the Power BI Embedded back-end...

https://community.powerbi.com/t5/Developer/Problem-using-page-getFilters/m-p/511911/highlight/true#M15792

Customers may receive an error while setting or getting page-level filters or visual-level filters using the Power BI embedded javascript API. As a workaround, customers can pass in any filter object in load config. Engineers are investigating the issue. Next update @ 9/10/18 at 9:00AM PDT.

As of the time of this answer however, the issue hasn't been fixed and the Power BI support page states the next update will be on 14th of September (2018), 10:00 PDT.

However, there is quite a simple work-around. Ensure you pass in an empty filter array into the embed configuration object, and everything works fine.

var embedConfig = {
  ...
  filters: [] //Empty array of filters.
};

var $reportContainer = $('#reportContainer');
var report = powerbi.embed($reportContainer.get(0), embedConfiguration);

Then you should be able to explicitly set report/page/visual filters in whichever order you like.

Upvotes: 1

Related Questions