Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hey,
So I am using getSlicerState to fetch slicer information. But when I fetch the filters attribute from the state object and apply it to the same slicer(just to check a successful function execution), I get the following error:
detailedMessage: "Filters target doesn't match slicer target"
message: "slicerTargetDoesNotMatch"
I understand it means that the target attribute in filters is to modify the filter value of the slicer and the targets attribute of slicer is used to modify associated tables. So they should be different, right?
Anyhow, applying the same state to the same filter should run. I believe my code shown below is correct, can any one guide or help me resolve this?
Code:
if (currentVisual.type == "slicer") {
currentVisual.getSlicerState()
.then(function (state) {
var slicerState = state["filters"][0];
if (slicerState != undefined) {
globalFilterObject[currentSlide][reportName].pages[activePage.name].slicers[currentVisual.name] = state;
currentVisual.setSlicerState({ filters: state.filters })
.then(function () {
console.log("Slicer was set.");
})
.catch(function (errors) {
console.log("Slicer Error: " + errors);
});
}
});
}
I also tried passing the entire state in setSlicerState instead of just setting the filters attribute of the slicer, unfortunately I'm facing the same error.
Code:
if (currentVisual.type == "slicer") {
currentVisual.getSlicerState()
.then(function (state) {
var slicerState = state["filters"][0];
if (slicerState != undefined) {
globalFilterObject[currentSlide][reportName].pages[activePage.name].slicers[currentVisual.name] = state;
currentVisual.setSlicerState(state)
.then(function () {
console.log("Slicer was set.");
})
.catch(function (errors) {
console.log("Slicer Error: " + errors);
});
}
});
}
Hi @Anonymous
i can't reproduce your problem, i suggest you to read through this link to know more about getting and setting slicers state using slicer APIs.
Best Regards
Maggie
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.