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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

getSlicerState throws an error - TypeError : slicer.getSlicerState is not a function

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);
    });

 

2 REPLIES 2
amshuste
Power BI Team
Power BI Team

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.

dax
Community Support
Community Support

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.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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