Forum Discussion
JagadishNallami
2 years agoFrequent Visitor
getSlicerState returning the not selected items instead of selected items
Hi there, I am having a slicer with hierachial data. When I tried to get the state of the slicer, I am getting the "Not selected" information instead of selected information like below. As it is ...
Anonymous
2 years agoNot applicable
Hi JagadishNallami ,
Base on your description, it seems like you are trying to get the selected values of hierarchies data in a slicer when using "getSlicerState" in Power BI. Please try the below codes:
Use slicers in Power BI embedded analytics | Microsoft Learn
// First, get the slicer state
slicer.getSlicerState().then(slicerState => {
// slicerState.values contains the state information
const selectedValues = slicerState.filters
.filter(filter => filter.isNotSelected === false) // Filter out the "NotSelected" items
.map(filter => filter.value); // Extract the selected values
console.log("Selected Values: ", selectedValues);
}).catch(error => {
console.error("Error fetching slicer state: ", error);
});
Best Regards