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.
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 a hierarchial data, I am having a tough time getting the selected data by filtering.
can anyone help me if there is a way to fetch the selected instead of NotSelected?
It helps a lot. Thank you in advance!!
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
User | Count |
---|---|
5 | |
5 | |
3 | |
2 | |
2 |
User | Count |
---|---|
10 | |
7 | |
5 | |
4 | |
4 |