Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi,
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)
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
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
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 11 | |
| 8 | |
| 8 | |
| 8 | |
| 8 |