Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
How can fix the error : - TypeError : slicer.getSlicerState is not a function , when trying to call the getSlicerState of the slicer API .
The following is the code:
var embedContainer = $('#embedContainer')[0];
report = powerbi.get(embedContainer);
report.getPages()
.then(function (pages) {
var activePage = pages.filter(function (page) {
return page.isActive;
})[0];
activePage.getVisuals()
.then(function (visuals) {
var slicer = visuals.filter(function (visual) {
return visual.type == "slicer" && visual.title == "Region";
})[0];
slicer.getSlicerState()
.then(function (state) {
console.log(state);
})
.catch(function (errors) {
console.log(errors);
});
})
.catch(function (errors) {
console.log(errors);
});
})
.catch(function (errors) {
console.log(errors);
});
Please try to check if your filter is right and that the "slicer" var is populated.
Make sure that the visual title is "Region"
visual.title == "Region"
We recommend to filter according to the visual name which is a unique identifier.
If the visual is filtered right, and you still get this error, please try to update your JavaScript SDK version.
Hi @Anonymous ,
I am not professional in javascript, so I suggest you could create a support ticket (https://powerbi.microsoft.com/en-us/support/) for more suggestions.
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
6 | |
6 | |
3 | |
2 | |
2 |