# TSVB ability to use tokens in panel filters that represent global time filter values to adjust viz based on global time selection

**URL:** <https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841>\
**Category:** Kibana\
**Created:** [October 27, 2021, 5:48pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841 "2021-10-27T17:48:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![catchsvix](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catchsvix/32/96423_2.png) [@catchsvix](https://discuss.elastic.co/u/catchsvix)\
**Post date:** [October 27, 2021, 5:48pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/1 "2021-10-27T17:48:59Z")

</div>

Apologies if I'm not using the correct terminology for the kibana fields I'm referring to.

I have a need to create a day-over-day (or WoW etc) comparison visualization for a given time range.  
I'm able to do it for a fixed time range (like today vs yesterday or today vs same day last week etc), but would like to have the ability to dynamically adjust my panel query to consider the global time range on the dashboard.

For instance, consider the screenshot below:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/c/ec05920c55b62546bbde3e53bbf9e36f29472fe7.png)

As can be seen, the panel filters hardcode for 'today' and comparison series are relative to that. If the global time range were to change to 'yesterday', my graph will show nothing as the data points fall off the range.

What I'd like to do in the panel is something like this:

'target series filter': "@timestamp\>{{earliest}} and @timestamp \<={{latest}}"

'comparison series (prev day) ': "@timestamp\>{{earliest}}-1d and @timestamp \<={{latest}}-1d"  
'comparison offset': 1d

where {{earliest}} and {{latest}} are tokens that represent the values from the global time range selection.

TIA for your help!

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [October 27, 2021, 6:16pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/2 "2021-10-27T18:16:02Z")

</div>

I don't think this is currently possible, but it seems like a very reasonable request. It seems similar to these two issues on GitHub:

> <https://github.com/elastic/kibana/issues/20896>
>
> Request for global time-picker value 
> 
> I would like to see if there is a way t…o pull the current days/hours that are being displayed and used as the time picker value. For example, if the user has selected 'Last 24 hours' this value would be 24. If it was 7 day it would be 7x24=168. I assume that current time picker works off what time range is displayed but for various reasons I cannot use those values. 
> 
> Here is a very simplistic use case for further explanation:
> Every user at a company works a variable number of hours a day. The executives would like a dashboard that shows the average number of hours worked over a certain time period for each employee plus for all employees. 
> 
> Here is a not so simplistic use case:
> On that dashboard an executive would want employees highlighted in red if they worked more than 40 hours in the last five workdays (depending on their scheduled days), green if they have worked less than 32 and yellow if they have between 32 and 40. However, if they are have worked between 1-4 hours over the last 10-14 consecutively , make them purple.
> 
> Obviously the first could be easily achieved in Kibana and probably maybe the second but for my situation that time picker value is embedded in a complicated math function. So knowing how much time is being displayed would be extremely helpful. I hope this makes sense.
> 
> 
> BTW, love the products you make

> <https://github.com/elastic/kibana/issues/13023>
>
> \<!--
> If you are filing a feature request, please remove the above bug
> report b…lock and provide responses for all of the below items.
> \--\>
> 
> \*\*Describe the feature\*\*:
> 
> Can I use timepicker value from kibana dashboard for the script?
> 
> I used this kind of script before.
> doc\['date1'\].value-doc\['date'\].value
> 
> What I want to do is that using start and end timepicker value(from dashboard) for calculating scripted field dynamically.
> doc\['date1'\].value - start timepicker value

I seem to remember there being another issue somewhere that was exactly this same request, but I couldn't find it. I'll keep digging!

---

<div class="post-metadata">

**Author:** ![catchsvix](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catchsvix/32/96423_2.png) [@catchsvix](https://discuss.elastic.co/u/catchsvix)\
**Post date:** [October 27, 2021, 6:24pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/3 "2021-10-27T18:24:08Z")

</div>

Thanks Lukas. Is there a place for me to officially request this feature? (or should I just upvote the links you provided above?)

---

<div class="post-metadata">

**Author:** ![catchsvix](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catchsvix/32/96423_2.png) [@catchsvix](https://discuss.elastic.co/u/catchsvix)\
**Post date:** [October 27, 2021, 6:30pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/4 "2021-10-27T18:30:35Z")

</div>

PS: the github issues seem to be pretty old

---

<div class="post-metadata">

**Author:** ![ghudgins](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ghudgins/32/138532_2.png) [@ghudgins](https://discuss.elastic.co/u/ghudgins)\
**Post date:** [October 27, 2021, 6:43pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/5 "2021-10-27T18:43:12Z")

</div>

sounds similar to this issue as well [[Lens] Time shift previous period · Issue #104259 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/104259)

...and, absent the specific solution, generally "Define tokens" (or variables) [Kibana: Define variables, e.g. for offset for timelion and Visual Timeseries Builder via GUI · Issue #33927 · elastic/kibana · GitHub](https://github.com/elastic/kibana/issues/33927)

these are definitely things on our backlog that we want to do

---

<div class="post-metadata">

**Author:** ![catchsvix](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catchsvix/32/96423_2.png) [@catchsvix](https://discuss.elastic.co/u/catchsvix)\
**Post date:** [October 27, 2021, 6:47pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/6 "2021-10-27T18:47:05Z")

</div>

Eagerly awaiting this feature... I'm sure this is a very common use case where one would want to compare events against a reference time range. Thanks in advance, Kibana team!

---

<div class="post-metadata">

**Author:** ![catchsvix](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/catchsvix/32/96423_2.png) [@catchsvix](https://discuss.elastic.co/u/catchsvix)\
**Post date:** [November 17, 2021, 6:24pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/7 "2021-11-17T18:24:11Z")

</div>

Hello team, is there a place to make this an official request that you triage? Or is there a place for us to contribute to the codebase and send a PR?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 15, 2021, 6:24pm UTC](https://discuss.elastic.co/t/tsvb-ability-to-use-tokens-in-panel-filters-that-represent-global-time-filter-values-to-adjust-viz-based-on-global-time-selection/287841/8 "2021-12-15T18:24:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
