Showing results for 
Search instead for 
Did you mean: 

getSlicerState() not working for slicers with hierarchy

The getSlicerState() call gives an error when it is called on a slicer which has hierarchy and where on the second level not all items are selected.


As you see in the image below, only cities 'Chicago' and 'Antwerpen' are selected on the second level.


If you make sure that you don't have 'incomplete' selections on the second level, the issue is not present.




This was probably also noticed here:


You can easily reproduce this in the new Power BI playground using this PBIX ( and the following code:



let loadedResolve, reportLoaded = new Promise((res, rej) => { loadedResolve = res; });
let renderedResolve, reportRendered = new Promise((res, rej) => { renderedResolve = res; });

// Embed a Power BI report in the given HTML element with the given configurations
// Read more about how to embed a Power BI report in your application here:
function embedPowerBIReport() {
    // Read embed application token
    let accessToken = EMBED_ACCESS_TOKEN;

    // Read embed URL
    let embedUrl = EMBED_URL;

    // Read report Id
    let embedReportId = REPORT_ID;

    // Read embed type from radio
    let tokenType = TOKEN_TYPE;

    // Get models. models contains enums that can be used.
    let models = window['powerbi-client'].models;

    // We give All permissions to demonstrate switching between View and Edit mode and saving report.
    let permissions = models.Permissions.All;

    // Create the embed configuration object for the report
    // For more information see
    let config = {
        type: 'report',
        tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed,
        accessToken: accessToken,
        embedUrl: embedUrl,
        id: embedReportId,
        permissions: permissions,
        settings: {
            panes: {
                filters: {
                    visible: true
                pageNavigation: {
                    visible: true

    // Get a reference to the embedded report HTML element
    let embedContainer = $('#embedContainer')[0];

    // Embed the report and display it within the div container.
    report = powerbi.embed(embedContainer, config);

    // removes all event handlers for a specific event"loaded");

    // report.on will add an event handler
    report.on("loaded", function () {

    report.on("error", function (event) {

    // removes all event handlers for a specific event"rendered");

    // report.on will add an event handler
    report.on("rendered", function () {

await reportLoaded;
await reportRendered;

// Retrieve the page collection and get the visuals for the first page.
try {
    const pages = await report.getPages();
    let pageWithSlicer = pages[0]; // Retrieve the page that contains the slicer
    const visuals = await pageWithSlicer.getVisuals();
    // Retrieve the slicer visual
    let slicer = visuals.filter(function (visual) {
        return visual.type === "slicer";

    // Get the slicer state
    console.log('trying to get the slicer state')
    const state = await slicer.getSlicerState();
    console.log('could get the slicer state')
catch (errors) {





Status: New
Community Support



You may check Limitations section and share feedback via Ideas.

Frequent Visitor

@v-chuncz-msft , ok... I find it very hard to see this as a limitation.  It basically voids the complete use case of getting & setting slicers.  Moreover, the JavaScript API just throws an exception in stead of passing an error message.  In order to cope with this behavior you need to implement a try...catch block.


Nevertheless, I created the suggestion: