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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Sssman
Regular Visitor

Slicer can't save user inputted values when switching page.

Hi,

I have created this slicer with help of ChatGPT because the default range slicer wasn't providing some customizations I wanted. For the most part, it works as expected, except for one thing, when I input values to the Min and Max box, the filter works but if I switch the page and go back to the page again, the Min and Max box will not show the user inputted values but the filter will still be active. 

I have uploaded the files here, can someone please help me save the user input values, I would really appreciate it.
https://github.com/suvojithaldar/CustomRangeSlicer

 

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @Sssman,

 

It sounds like you're restoring the filter state from the visual host correctly when your visual reinitializes on page change, so at least the visuals are filtered correctly. You will have the responsibility of updating your UI.

 

For any input elements, you'll need some logic in there to fill them in - there would be two ways I'd consider this:

 

  1. If restoring from the persisted filter state is acceptable, process your filter JSON to obtain the min and max values and make these the initial values of the corresponding input elements.
  2. If the exact values the user typed are what you want to store (as Power BI may adjust the persisted filter to suit the data and may not reflect the user's original input 100%). In this case, I'd consider this approach:
    • Create properties to store the type values and persist them using the IVisualHost.persistProperties API.
    • These properties can be read when your visual reinitializes and populates into the input elements similar to the above mechanism.
    • Keeping these properties hidden from the user when you create your formatting model so they cannot be manually modified from the pane (this could be fine if you don't mind them being visible, but bear in mind that you'll need to 'sync' them both ways rather than assuming that they'll only be written to from the visual).

Good luck!

 

Daniel





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




View solution in original post

2 REPLIES 2
dm-p
Super User
Super User

Hi @Sssman,

 

It sounds like you're restoring the filter state from the visual host correctly when your visual reinitializes on page change, so at least the visuals are filtered correctly. You will have the responsibility of updating your UI.

 

For any input elements, you'll need some logic in there to fill them in - there would be two ways I'd consider this:

 

  1. If restoring from the persisted filter state is acceptable, process your filter JSON to obtain the min and max values and make these the initial values of the corresponding input elements.
  2. If the exact values the user typed are what you want to store (as Power BI may adjust the persisted filter to suit the data and may not reflect the user's original input 100%). In this case, I'd consider this approach:
    • Create properties to store the type values and persist them using the IVisualHost.persistProperties API.
    • These properties can be read when your visual reinitializes and populates into the input elements similar to the above mechanism.
    • Keeping these properties hidden from the user when you create your formatting model so they cannot be manually modified from the pane (this could be fine if you don't mind them being visible, but bear in mind that you'll need to 'sync' them both ways rather than assuming that they'll only be written to from the visual).

Good luck!

 

Daniel





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

Proud to be a Super User!


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Sssman
Regular Visitor

Thanks a lot! I was able to save the user input using the first method that you suggested.

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 FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors