Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div id="container"></div>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
- <script src="powerbi.min.js"></script>
- <script>
- var container = document.getElementById("container");
- // -------------------------------------------------------------------------
- // Power BI Authentication/Session:
- // -------------------------------------------------------------------------
- // Guide: https://docs.microsoft.com/en-us/power-bi/developer/walkthrough-push-data-get-token
- // 1. You need to acquire an AccessToken on the backend (don't do this over JS)
- // 2. You will need to find the report you want to display
- // 3. You just need the accessToken, reportId, and embedUrl to embed
- // -------------------------------------------------------------------------
- var accessToken = "", // the active session; it will expire after several minutes
- reportId = "", // the guid id connected to the Power BI file you uploaded
- embedUrl = ""; // the embed URL for that report
- var report = powerbi.embed(container, {
- type: "report",
- accessToken: accessToken,
- id: reportId,
- embedUrl: embedUrl,
- settings: {
- filterPaneEnabled: false,
- navContentPaneEnabled: false
- }
- });
- // Filter variables
- var targetTable = "tblSomeData", // The target table in the Power BI report you want to filter against
- targetColumn = "Title", // The column you want to filter on
- targetValue = "Mr. Smith", // The value you want to search for
- operatorCondition = "Contains"; // The operator condition you want to use for the search
- // Filter being done:
- // 1. Search the "Title" column of the "tblSomeData" Table
- // 2. Look for records containing "Mr. Smith"
- report.setFilters([{
- $schema: "http://powerbi.com/product/schema#advanced",
- target: {
- table: targetTable,
- column: targetColumn
- },
- logicalOperator: "OR",
- conditions: [{ operator: operatorCondition, value: targetValue }]
- }]).then(function (result) { console.log("Filtered!"); })
- .catch(function (er) { console.warn(er); });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement