Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
We are trying to save the state of the slicers and apply them.
We get the state using getSlicerState () and, on the onLoad event, we try to apply them with .setSlicerState(),
When we try to apply the saved state, we get an error:
The state that we save and try to apply:
Why we can't use the saved state for the same slicer аnd what do we need to do to apply them?
For other slicers, it works correctly, the problem only with Hierarchy Slicer.
Solved! Go to Solution.
Hi @Dzvene ,
Please try to provide a target of type IFilterHierarchyTarget. example:
const basicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Store",
hierarchy: "Country",
hierarchyLevel: "Code"
},
operator: "In",
values: [456, 943],
filterType: pbi.models.FilterType.BasicFilter
};
visual.setSlicerState({
filters: [basicFilter]
});
Reference:
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Slicers
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I tried the same format for the filter and I am still getting the same error.
Hi @Dzvene ,
Please try to provide a target of type IFilterHierarchyTarget. example:
const basicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Store",
hierarchy: "Country",
hierarchyLevel: "Code"
},
operator: "In",
values: [456, 943],
filterType: pbi.models.FilterType.BasicFilter
};
visual.setSlicerState({
filters: [basicFilter]
});
Reference:
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Slicers
Best Regards,
Xue Ding
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.