Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Reply
mattkocak
Kudo Kingpin
Kudo Kingpin

Retain user's visual state for custom slicer (persist state)

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?

  1. Persist the "clicked" state for the custom slicer between an indivual user's viewing sessions
  2. Remove previous Persistent Filters that were applied from the custom slicer when the visual is reloaded

 

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.

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

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





Did I answer your question? Mark my post as a solution!

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)




View solution in original post

3 REPLIES 3
Borowik
Frequent Visitor

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 

dm-p
Super User
Super User

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





Did I answer your question? Mark my post as a solution!

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!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.