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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors