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 September 15. Request your voucher.

Reply
FrançoisD
Frequent Visitor

I can't get the "single selection required" real value of a slicer with the client API

Hello,

 

I have a report with a categorical slicer. This slicer has "single select" checked and renders as a "one selection" visual:

 

FranoisD_0-1718781081297.pngFranoisD_1-1718781093662.png

 

However, when I use the client API in embed mode, when I get this slicer and then run `const state = await slicer.getState()`

the `state.filters[0].requireSingleSelection` is always set to false whatever the check status on my report.

Is it a known issue or is it because I get the wrong attribute?

 

2 REPLIES 2
Anonymous
Not applicable

Hi @FrançoisD ,

Please review the following links, hope they can help get the expected result...

Get slicer state

Slicers · microsoft/PowerBI-JavaScript Wiki · GitHub

let state = await visual.getSlicerState();
// Get the list of visuals from the report
report.getPages()
    .then(function(pages) {
        return pages[0].getVisuals();
    })
    .then(function(visuals) {
        // Find the slicer visual by name or other properties
        let slicer = visuals.find(function(visual) {
            return visual.type === 'slicer' && visual.name === 'SlicerVisualName';
        });

        // Get the state of the slicer
        return slicer.getSlicerState();
    })
    .then(function(slicerState) {
        // Access the selected value
        let selectedValue = slicerState.targets[0].target;
        console.log('Selected Value:', selectedValue);
    })
    .catch(function(errors) {
        console.error(errors);
    });

Best Regards

Hello,

Thanks for your reply but, it does not answer my question at all.

I am already using the getSlicerState function and I can already get the selected value and even set it.

My issue is that I cannot programmatically make the difference between a slicer that only accept one selected value and a slicer that accept many because the "requireSingleSelection" boolean is always set to "false" in the state.filters attribute.

Regards

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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