Forum Discussion
Embedded report showing old rendering
Hi Hougaard77,
Where did you set the filter, in the onload event, or other event?
The Power BI Javascript should support setting filter when embedding without the rendering issue. Following is a similar thread for reference: https://community.powerbi.com/t5/Developer/how-to-create-custom-filters-for-power-bi-embedded-reports-using/td-p/141494
The Power BI Javascript support set filter when embedding. Check this wiki. You can find a more integrated live demo by clicking Custom Filter Pane.
A simple demo I use to test for your reference.
<html> <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/jquery/dist/jquery.js"></script> <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/node_modules/powerbi-client/dist/powerbi.js""></script> <script type="text/javascript"> var embedConfiguration = { type: 'report', accessToken: 'token', embedUrl: 'embedURL' }; var report; window.onload = function () { var $reportContainer = $('#reportContainer'); report= powerbi.embed($reportContainer.get(0), embedConfiguration); var Filter1 = { $schema: "http://powerbi.com/product/schema#advanced", target: { table: "Table1", column: "T1id" }, logicalOperator: "OR", conditions: [ { operator: "Contains", value: "id1" } ] } report.on('loaded', event => { report.getFilters() .then(filters => { filters.push(Filter1);
return report.setFilters(filters); }); }); } function reloadreport(){ var $reportContainer = $('#reportContainer'); powerbi.embedNew($reportContainer.get(0), embedConfiguration); }; </script> <div id="reportContainer"></div> </html>
Regards
- Hougaard778 years agoRegular Visitor
Hi,
First of all, I tried specifying the filter in the embedConfiguration
Then I applied it in the loaded event which causes the same behaviour: Data from the previous rendering is shown until a refresh has been completed (takes 5 seconds or so)
Finally I tried applying the filter in the onload event but that seems to cause the filter to be completely ignored after switching between pages in the report.
So, unfortunately the issus is not solved. I event tried applying a "front page" to my report and setting navContentPaneEnabled to false until the rendered event would set it true. But that event fires as soon as the front pages has been rendered and the other pages still contain data that does not match the filter.
Looking forward to you advice,
Erik
- ragh10848 years agoAdvocate I
Hello Erik,
Have you found any solution? i tried to put cache control = No. but still the iframe initially displays old data for fraction of 5 seconds and then filters based on the criteria chosen.
- Hougaard778 years agoRegular Visitor
Hi,
Sorry about the late reply. I was notified about your question only now - 2 months after you posted it :-)
I did not manage to find a solution. In this particular project we decided to build our reporting around chartJS instead.
Best regards,
Erik