# Control the widget value with reactive expressions

**URL:** <https://discourse.holoviz.org/t/control-the-widget-value-with-reactive-expressions/8610>\
**Category:** Panel\
**Tags:** widgets, interactive\
**Created:** [February 28, 2025, 11:12pm UTC](https://discourse.holoviz.org/t/control-the-widget-value-with-reactive-expressions/8610 "2025-02-28T23:12:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![matipos2](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/matipos2/32/7101_2.png) [@matipos2](https://discourse.holoviz.org/u/matipos2)\
**Post date:** [February 28, 2025, 11:12pm UTC](https://discourse.holoviz.org/t/control-the-widget-value-with-reactive-expressions/8610/1 "2025-02-28T23:12:23Z")

</div>

I’m building data store. I want to have range sliders for filtering the data. The data will be shown by some category (`string`), in the example below it is model name. Each model may have different ranges.  
Until now everything is fine. I’m selecting different models and ranges are being updated accordingly. But the problem comes when I want to control pre-selected range. For example last x days for `DateRangeSlider` or some subset of `RangeSlider`.

I can’t use `param.reactive.rx` for the `value` property like I’m using it for the `min` and `max`. It must be corresponding value: `datetime`, `int`, etc.  
`ValueError: DateRange parameter 'DateRangeSlider.value' only takes date/datetime values, not <class 'param.reactive.rx'>.`

If you use the working solution: `*.rx.value` you loose the interactivity.

How can I setup the value and not loose the interactivity?

Example:

```python
import panel as pn
import pandas as pd
import datetime
import param
from panel.viewable import Viewer

class DataStore(Viewer):
    data = param.DataFrame()
    model = param.String(allow_refs=True)

    def __init__ (self, **params):
        super(). __init__ (**params)
        dfx = self.param.data.rx()
        # filter out only selected model
        dfx = dfx[dfx['t_model'] == self.param.model]
        max_date = dfx['t_img_date'].max()
        self.date_slider = pn.widgets.DateRangeSlider(start=dfx['t_img_date'].min(), end=max_date,
                                                      value=(max_date.rx.value - datetime.timedelta(days=163), max_date.rx.value),
                                                      step=31, sizing_mode='stretch_width'
                                                      )
        # filter by date
        dfx = dfx[dfx['t_img_date'].between(*self.date_slider.rx())]
        self.int_slider = pn.widgets.RangeSlider(start=dfx['case_id'].min(), end=dfx['case_id'].max(),
                                                 value=(dfx['case_id'].min().rx.value + 1, dfx['case_id'].max().rx.value - 1)
                                                 )
        # filter by cap
        self.data_filtered = dfx[dfx['case_id'].between(*self.int_slider.rx())]

    def __panel__ (self):
        self.date_slider.servable()
        self.int_slider.servable()
        pn.widgets.Tabulator(self.data_filtered, page_size=20, pagination='remote').servable()

pn.extension('tabulator', theme='dark', sizing_mode='stretch_width')

data_url = "https://assets.holoviz.org/panel/tutorials/turbines.csv.gz"
df = pn.cache(pd.read_csv)(data_url)
df = df.dropna()
df['t_img_date'] = pd.to_datetime(df['t_img_date']).dt.date

model_selector = pn.widgets.Select(options=df['t_model'].unique().tolist(),
                                   sizing_mode='fixed', width=200)

model_selector.servable()

ds = DataStore(data=df, model=model_selector)
ds.servable()

```

---

<div class="post-metadata">

**Author:** ![ahuang11](https://discourse.holoviz.org/user_avatar/discourse.holoviz.org/ahuang11/32/4947_2.png) [@ahuang11](https://discourse.holoviz.org/u/ahuang11)\
**Post date:** [March 3, 2025, 5:31pm UTC](https://discourse.holoviz.org/t/control-the-widget-value-with-reactive-expressions/8610/2 "2025-03-03T17:31:37Z")

</div>

Maybe you can file an issue on Panel (even if it doesn’t end up being a bug, documentation could be improved).
