Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
davidjackson
Regular Visitor

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 4
davidjackson
Regular Visitor

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]
};

 

@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>

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);
                    };
Anonymous
Not applicable

I am seeing the same thing. Did you ever get this figured out?

 

Thanks,


Stizz001

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors