Forum Discussion

davidjackson's avatar
davidjackson
Regular Visitor
9 years ago

Filter not working, just reloading the page

Hi All

 

I have a powerBI embedded report using a PBIX with embedded csv data. The report shows up find but I can't filter on it.

I created a test below to try but all that happens when I try is it reloads the page.

 

The problem seems to be with removeFilters() and getFilters()

Both are throwing an error that I can't trap :(

Any help would be very much appreciated

 

 

function addFilter() {
//clearFilters();
//debugger;
//var target = $('#filter-target').val();
//var table = $('#filter-table').val();
//var column = $('#filter-column').val();
//var value = ''; // $('#filter-value').val();
var basicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
//table: "tblEIMMaster",
//column: "Activity"
table: "Eimdata20170203",
column: "ID"
},
operator: "In",
values: [69872, 69719, 69863, 69880, 69598, 69604, 68796, 69555, 69091, 67951]
};

 

4 Replies

  • Hi All

     

    I have a powerBI embedded report using a PBIX with embedded csv data. The report shows up find but I can't filter on it.

    I created a test below to try but all that happens when I try is it reloads the page.

     

    The problem seems to be with removeFilters() and getFilters()

    Both are throwing an error that I can't trap :(

    Any help would be very much appreciated

     

    function addFilter() {
    //clearFilters();
    //debugger;
    //var target = $('#filter-target').val();
    //var table = $('#filter-table').val();
    //var column = $('#filter-column').val();
    //var value = ''; // $('#filter-value').val();
    var basicFilter = {
    $schema: "http://powerbi.com/product/schema#basic",
    target: {
    //table: "tblEIMMaster",
    //column: "Activity"
    table: "Eimdata20170203",
    column: "ID"
    },
    operator: "In",
    values: [69872, 69719, 69863, 69880, 69598, 69604, 68796, 69555, 69091, 67951]
    };

     

    • Eric_Zhang's avatar
      Eric_Zhang
      Icon for Microsoft Employee rankMicrosoft Employee

      davidjackson

      The basic filter actually works in my test. Check my demo, replace the token and reportid with them in your case.

       

      <html>
      
       <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/powerbi-client/dist/powerbi.js"></script>
       
       <script src="https://microsoft.github.io/PowerBI-JavaScript/demo/bower_components/jquery/dist/jquery.js"></script>  
       
      <script type="text/javascript">
      window.onload = function () { 
        var  IamAFilter = {
              $schema: "http://powerbi.com/product/schema#basic",
        target: {
          table: "Eimdata20170203",
          column: "ID"
        },
        operator: "In",
        values: [69872, 69719, 69863, 69880, 69598, 69604, 68796, 69555, 69091, 67951]
      }
       
      
      var embedConfiguration = {
          type: 'report',
          accessToken: 'eyJ0eXAiOiJKV1QiLxxxxa3NwY0NsbGN0xxxxxxxxxxxxxDMzYxxxxxRmMi1kOWxxxxI0NjEiLCJyaWQiOiJlNmI4ZmY0Yy1lZjE2LTRkZDItOWIxNy1jNDk2Mjg3NDFmOGYiLCJ1c2VybmFtZSI6IkVSSUNaSEFORyIsInJvbGVzIjoiU2VlMXN0IiwiaXNzIjoiUG93ZXJCSVNESyIsImF1ZCI6Imh0dHBzOi8vYW5hbHlzaXMud2luZG93cy5uZXQvcG93ZXJiaS9hcGkiLCJleHAiOjE0ODkwMzI1NjcsIm5iZiI6MTQ4OTAyODk2N30.xoYHlGQ3Cy95DfW55EOZIgGxT5oZ5cLgNfUBttkaKDw',
           
          embedUrl: 'https://embedded.powerbi.com/appTokenReportEmbed?reportId=xxxxx17-c49628741f8f',
      	filters:[IamAFilter], // the filters is an array here, you can add more filter like [filter1,filter2,filter3]
      	settings: {
              filterPaneEnabled: true //hide the filterPane so that your user can't change the filter to see more data, this is not a strong security, anyone who's familar with javascript can bypass it
          }
      
      }; 
       
      
      var $reportContainer = $('#reportContainer');
       
      var report = powerbi.embed($reportContainer.get(0), embedConfiguration); 
      
      
      }
      </script>
      
      <div id="reportContainer" powerbi-settings-nav-content-pane-enabled="true"   powerbi-settings-filter-pane-enabled="true"></div>
      
      </html>
      
      • davidjackson's avatar
        davidjackson
        Regular Visitor

        I've narrowed it down to here (see below)

         

        for some reason the "targetWindow" value is not available

         

                            HttpPostMessage.prototype.send = function (request, targetWindow) {
                                if (targetWindow === void 0) { targetWindow = this.defaultTargetWindow; }
                                request.headers = this.assign({}, this.defaultHeaders, request.headers);
                                if (!targetWindow) {
                                    throw new Error("target window is not provided.  You must either provide the target window explicitly as argument to request, or specify default target window when constructing instance of this class.");
                                }
                                return this.windowPostMessageProxy.postMessage(targetWindow, request);
                            };