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.
I am using a filter on my Power BI embedded report to select the customer number to show a particular customer his data. The filter is set using JavaScript according to the tutorials online.
However, when opening the report, it often shows another customer's data until a new report is loaded. It seems that the old rendering is saved. But obviously I need the report to start out blank and then apply the filter instead of showing the wrong data and revealing one customers report to the other.
How can I make that happen?
Best regards,
Erik
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-report...
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
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
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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.