Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
I'm creating a custom slicer, but have run into an issue. If a user clicks on my custom slicer and reloads the page, then the filter from the custom slicer will still be retained, but the custom slicer visual will no longer appear as selected.
Obviously this is less than ideal as users will often close a page with the custom slicer selected. Then when they reopen the page, data will be filtered, but there will be no indication as to why (the custom slicer visual won't appear selected).
The built-in Power BI slicer will still appear selected when a user reloads the page, but I haven't found a way to mimic that with custom visual development. Maybe the Local Storage API, but that would require the visual to already be available in the AppSource and certified 🙄 I've also looked into the persistProperties fuction, but my understanding is that that persists properties on the visual-level, rather than the user-level (i.e. properties when someone is editing a Power BI report, rather than just viewing one).
Anyway, does anyone have a solution for either of the following solutions?
As far as option 2 goes, I guess the report creator could just disable Persistent Filters for the whole report, but I would prefer a more "automatic" solution.
Solved! Go to Solution.
Hi @mattkocak,
I have to admit it's been a little while since I've developed a slicer, but from what I remember, the visual host returns the slicer state upon updates (for cases like yours) and you just need to parse it and apply it to your visual's logic so that it represents the persisted state being returned. Have you tried this already?
Regards,
Daniel
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Hi, I am curious if you find the way to save a state of slicer upon page reload, I have custom date range picker and looking for solutions once button is pressed , visual keep state across all report pages , many thanks for replying
Hi @mattkocak,
I have to admit it's been a little while since I've developed a slicer, but from what I remember, the visual host returns the slicer state upon updates (for cases like yours) and you just need to parse it and apply it to your visual's logic so that it represents the persisted state being returned. Have you tried this already?
Regards,
Daniel
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Excellent. The VisualUpdateOptions.jsonFilters array stores the filters applied from a visual between page reloads. With this info available, one can accomplish either solution 1 or 2 from my original post. Thanks!
User | Count |
---|---|
8 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
11 | |
3 | |
2 | |
2 | |
2 |