March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
24 | |
23 | |
12 | |
11 | |
8 |
User | Count |
---|---|
44 | |
43 | |
24 | |
11 | |
10 |