Forum Discussion
giangn
8 years agoFrequent Visitor
Embeded Report - How to show visual filter in default after loading report
Hello guys, I have embeded report with single visual (a table). I need to show visual filter after loading report without any end-user click to visual. By default, the panel is blank because we don...
v-jiascu-msft
8 years agoMicrosoft Employee
Hi giangn,
Please refer to the live demo. You will find the way to get filters. You also can download the source code from here.
// Build the filter you want to use. For more information, See Constructing
// Filters in https://github.com/Microsoft/PowerBI-JavaScript/wiki/Filters.
const filter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Store",
column: "Chain"
},
operator: "In",
values: ["Fashions Direct"]
};
// Get a reference to the embedded report HTML element
var embedContainer = $('#embedContainer')[0];
// Get a reference to the embedded report.
report = powerbi.get(embedContainer);
// Retrieve the page collection and get the visuals for the first page.
report.getPages()
.then(function (pages) {
// Retrieve active page.
var activePage = pages.find(function(page) {
return page.isActive
});
activePage.getVisuals()
.then(function (visuals) {
// Retrieve the wanted visual.
var visual = visuals.find(function(visual) {
return visual.name == "VisualContainer3";
});
// Set the filter for the visual.
// Pay attention that setFilters receives an array.
visual.setFilters([filter])
.catch(function (errors) {
Log.log(errors);
});
})
.catch(function (errors) {
Log.log(errors);
});
})
.catch(function (errors) {
Log.log(errors);
});
Best Regards,
Dale
giangn
8 years agoFrequent Visitor
Hi v-jiascu-msft,
I can setfilter for visual but i mean i want to show report with Visual Filter panel when loaded report.
What default embed show:
What i need after load report:
Currently end-user maybe don't know click to visual to show filter, they only see filter is blank when completed load report, That's bad for end-user experience.
Please help me a solution for that.