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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sjungels
Frequent Visitor

Power BI Embedded - Filter Setting and UI Rendering

pbi.pngHi, 

 

Below is my javascript in my html:

 

<script type="text/javascript">
var report;
var accessToken = "{{ token }}";
var embedUrl = "{{ embed_url }}";
var embedReportId = "{{ report_id }}";
var models = window['powerbi-client'].models;
var page = "{{ layout }}";

var basicFilter = {
$schema: "http://powerbi.com/product/schema#advanced",
target: {
table: "analysis_hierarchy",
column: "l2_name"
},
logicalOperator: "OR",
conditions: [
{
operator: "Contains",
value: "West"
},
{
operator: "Contains",
value: "East"
}
]
};

var embedConfiguration = {
type: 'report',
pageName: page,
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All,
settings: {
navContentPaneEnabled: false
{#filterPaneEnabled: false#}
}
};

window.onload = function () {

var $reportContainer = $('#reportContainer');
report = powerbi.embed($reportContainer.get(0), embedConfiguration);
console.log("report rendered... now setting filter");
report.on('loaded', event => {
report.getFilters()
.then(filters => {
console.log("before pushing filter");
filters.push(basicFilter);
console.log("after pushing filter");

return report.setFilters(filters);
console.log("after setting filter");

});
});
};

</script>

 

I am getting a javascript exception:

 

Uncaught (in promise)

  1. {message: "InvalidFilter", detailedMessage: "Invalid filter definition", errorCode: undefined, level: 3, technicalDetails: {…}}
    1. detailedMessage"Invalid filter definition"
    2. errorCodeundefined
    3. level3
    4. message"InvalidFilter"

 

I tried various different ways of creating filters, also passing filters directly into the embed() function, but none of them work. 

 

Also, when embedding the report, the size rendered doesn't use all the real-estate even though I give the div's enough space (red and blue border):

 

I am importing the following:

<!-- Microsoft Power BI -->
<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>

 

After this import, I am loading Bootstrap CSS and JavaScript. I also tried adding the MS JavaScript to the end of the <body> tag. Nothing seem to do anything...

 

Any ideas? 

 

Thanks,
Sebastian

 

1 REPLY 1
v-yuta-msft
Community Support
Community Support

Hi sjungels,

 

How about using advanced filter? Similar case for your reference: https://community.powerbi.com/t5/Developer/Two-advanced-date-filters-with-javascript-api/td-p/128294. In addtion, if still can't solve your issue, you can submit your issue to developer forumn for further support or create a support ticket here.

 

Regards,

Jimmy Tao

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors