Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have some basic questions I need some help with:
1) if I simply include the following JS, I can use all of PBI functionality, i.e. I do not need to download the sources via nuget or npm, etc, correct?
<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>
2) I'd like to display a report with a default filter. All examples I am finding is to set the report filter afterwards. Can't I simply add a filter to the Embed Configuration?
3) When using the filters, do they need to be pre-defined as report / page filters or can I just pass anything?
Thanks!
You can reference the JavaScript library files from a CDN. That works fine. However, I wiould not use the links below because they point to a sample site.
Instead, use these:
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="https://github.com/Microsoft/PowerBI-JavaScript/raw/master/dist/powerbi.js" ></script>x
With filter, you can set any filter you want as long as you know the table name and column name to filter.
To set the filter before the report is displayed, you must use phased loading. Note that you should use powerbi.load instead of powerbi.embed to load the report without displaying it. Then when the load event fires you can set a report filter and then call report.render(config) to display the report after you set your filter.
// data required for embedding Power BI report var embedReportId = "5dc619ea-d9ab-40cf-8a31-f1e0c480e520"; var embedUrl = "https://app.powerbi.com/reportEmbed?reportId=5dc619ea-d9ab-40cf-8a31-f1e0c480e520&groupId=54afb565-3935-47e1-9a89-67e48a78ca45&config=eyJjbHVzdGVyVXJsIjoiaHR0cHM6Ly9XQUJJLVVTLUVBU1QyLXJlZGlyZWN0LmFuYWx5c2lzLndpbmRvd3MubmV0In0%3d"; var accessToken = "H4sIAAAAAAAEAC2Wx66E7HJF3-WftiVysnQH8JEzNHlGDk3OcOV397mW5zUo7V1aq_79j50-_ZQW__z3P4Q9t7lvX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rqyc457R7aVqQhPjPQiQJBRkP0ORW2hSDK9kE9EK0RDBLq-h8pWyMKKEMYxssaQXVwPxKFYKLDULWu9467s6yA_nO1lSRYjSgOn_Pc3RWbIx_E5ClsyN_PkdkeCdsEfr14Mf9iGYlOEKLXiQSYyZmBvW__vXPf_0D1mfeJ618_t6kzCoeE9Yjo_wKkyCKG6q24Kr81utxcMPleL1HoeIGVQ06qnhwo4Pdv6Y_GUIapxlTS6XVLLR6dFKLm5ofCoWu2YnccUh55s9qmQatuiJw37LiGIpfkL8IPyJRcsh0y3-Quxy3bkSlg8agexlp5tD6j7xxPCn19KO_qJg82RcAd1wg2pMUyGPrXB239e9GaLuON_VsGrhjmGR83qtchV3xPUkylg7mAKs4o9ydg1DebvozKz9sOy9k2VVlP197YCggc1ESzTsSQK3X3Q5j-8Zv2ia9UNYtppLbPaGfao4c0cSpKkxTVgqoA-zJy_7KRKUdk6gOGcAR3InBvCsyyB1RePr_x_zMTbkqwV_K-itGdXh5YYajVKyzyw8btOv_pr5tPab7sZZ_Y4lsbAcS8C1ZwfVwh6OFyfQkqOdGt7dtTrJxhLq4Qe2fXlsYqsT0k4hNONWUkULCcGFJ-BFNO6rlacw3jDKfe7wX-p5Lsu6RG9jjW-HJF5mJDPpMfb0temtUiQkDozXOKXZjpb124iE8gqIakTK1EQ0OmoRZSlq-H6_ieZc9-yEy8EU_qd8SolPAML2avexykqfWhNKdZMVQBTrOQTr23N_3x8QDLGn3tk7viitiSA8fL6j3z0ey3AatUPckTV89c53v5owKNWQ9D91R0e-WYEqHC_eUTgyrH8ze6HBr8zusYVFnQ2ey2Lyk7NCobL-Dojt1v265egBTLx7pogWgjWGK_xPz__wvlOIwVhoMAAA="; // Get models object to access enums for embed configuration var models = window['powerbi-client'].models; var config = { type: 'report', id: embedReportId, embedUrl: embedUrl, accessToken: accessToken, tokenType: models.TokenType.Embed, }; // Get a reference to the embedded report HTML element var reportContainer = document.getElementById('embedContainer'); // call load() instead of embed() to load the report while delaying the rendering process var report = powerbi.load(embedContainer, config); // when loaded event occurs, set current page then call render() report.on("loaded", function () { const basicStateFilter = { $schema: "http://powerbi.com/product/schema#basic", target: { table: "Customers", column: "State" }, operator: "In", values: ["FL", "GA", "TX"] } report.setFilters([basicStateFilter]); // display the report report.render(config); });
Thanks, Ed, for your answer.
When I include the github link, I still get an error:
>> Refused to execute script from 'https://raw.githubusercontent.com/Microsoft/PowerBI-JavaScript/master/dist/powerbi.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
When I use my old include, I get this:
Thanks!
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
2 |
User | Count |
---|---|
10 | |
7 | |
4 | |
4 | |
4 |