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.
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.
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.
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.