# Using X-axis values in queries to determine Y-axis in Kibana

**URL:** <https://discuss.elastic.co/t/using-x-axis-values-in-queries-to-determine-y-axis-in-kibana/133458>\
**Category:** Kibana\
**Created:** [May 28, 2018, 5:46am UTC](https://discuss.elastic.co/t/using-x-axis-values-in-queries-to-determine-y-axis-in-kibana/133458 "2018-05-28T05:46:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjain](https://avatars.discourse-cdn.com/v4/letter/r/5f9b8f/32.png) [@rjain](https://discuss.elastic.co/u/rjain)\
**Post date:** [May 28, 2018, 5:46am UTC](https://discuss.elastic.co/t/using-x-axis-values-in-queries-to-determine-y-axis-in-kibana/133458/1 "2018-05-28T05:46:01Z")

</div>

I am trying to visualize duration data on Kibana and my data has both a start-time and an end-time. If I use timelion, I need to get the time value to include data s.t. start-time\<=time on x axis\<=end-time in the count for that particular time.

Is it possible to do this? I am looking for a non-timelion specific way so that I can use other visualizations if required.

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [May 28, 2018, 8:01am UTC](https://discuss.elastic.co/t/using-x-axis-values-in-queries-to-determine-y-axis-in-kibana/133458/2 "2018-05-28T08:01:18Z")

</div>

I think what you want is, to actually include the duration (end-time - start-time) into the document. You could either do that by using a [scripted field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) with a scrip like `doc['end-time'].value - doc['start-time'].value` (and some `null` checks if those are optional fields. Or an even faster solution, insert that field directly when ingesting that documents into Elasticsearch by let your ingestion pipeline calculate it.

That way you can use the newly "duration" field in any chart you want.

Cheers,  
Tim

---

<div class="post-metadata">

**Author:** ![rjain](https://avatars.discourse-cdn.com/v4/letter/r/5f9b8f/32.png) [@rjain](https://discuss.elastic.co/u/rjain)\
**Post date:** [May 28, 2018, 9:55am UTC](https://discuss.elastic.co/t/using-x-axis-values-in-queries-to-determine-y-axis-in-kibana/133458/3 "2018-05-28T09:55:36Z")

</div>

Hey Tim!

I actually want to count all 'active' records at each time.

A record is active iff its start time is \< timestamp and end time is \> timestamp

Here timestamps will be plotted on the x axis as a time series

---

<div class="post-metadata">

**Author:** ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)\
**Post date:** [May 28, 2018, 10:36am UTC](https://discuss.elastic.co/t/using-x-axis-values-in-queries-to-determine-y-axis-in-kibana/133458/4 "2018-05-28T10:36:12Z")

</div>

Hey,

this will not be possible outside of timelion, since it would require to work on the same index with different time fields at the same time. I also gave a rather detailed explanation in [this forum post](https://discuss.elastic.co/t/follow-up-metrics-of-daily-open-count-from-open-and-closed-date-and-create-bar-chart/131352/) that is about pretty much the same problem (even though it's a bit different domain of data).

Cheers,  
Tim

---

<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:** [June 25, 2018, 10:36am UTC](https://discuss.elastic.co/t/using-x-axis-values-in-queries-to-determine-y-axis-in-kibana/133458/5 "2018-06-25T10:36:15Z")

</div>

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