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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.