# Date range value for data table

**URL:** <https://discuss.elastic.co/t/date-range-value-for-data-table/206111>\
**Category:** Kibana\
**Created:** [November 1, 2019, 3:28am UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111 "2019-11-01T03:28:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amphagory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amphagory/32/46127_2.png) [@Amphagory](https://discuss.elastic.co/u/Amphagory)\
**Post date:** [November 1, 2019, 3:28am UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111/1 "2019-11-01T03:28:48Z")

</div>

Is there a way to obtain the value of the date range in terms of start and end times, last x mins, etc...

I would like to put this value into a data table.

i.e.

```auto
Animal Number Date range Average
                        (mins) (per min)
Dogs 30 15 2
Cats 90 15 6
```

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [November 1, 2019, 2:22pm UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111/2 "2019-11-01T14:22:56Z")

</div>

Can you provide some more information like your index mapping and some sample documents?

Kibana does not support ranges yet but you could store the range in the document or use a [scripted field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) to calculate the range at query run time.

---

<div class="post-metadata">

**Author:** ![Amphagory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amphagory/32/46127_2.png) [@Amphagory](https://discuss.elastic.co/u/Amphagory)\
**Post date:** [November 1, 2019, 3:39pm UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111/3 "2019-11-01T15:39:09Z")

</div>

I might have not made my question clear.

I was speak to the data range query as part of the Kibana:

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

I was wondering if we could grab either the absolute or relative value.

In the above image, the user has selected relative with the value of 15.

I'm wondering if we could obtain number 15 and the unit (minutes, hours, etc...)

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [November 1, 2019, 6:11pm UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111/4 "2019-11-01T18:11:08Z")

</div>

You can basically do this using the Sibling Pipeline aggregation. So for example, I have set up a table using the sample ecommerce data:

 ![24](https://us1.discourse-cdn.com/elastic/original/3X/3/d/3dfd9ee147de6f338412354057d0c2e97ef43e4a.png)

This table shows that I am calculating a Date Histogram using the interval selected, which in this case was 24 hours. So this aggregation returns the following data from Elasticsearch:

```auto
"aggregations": {
    "2": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 19,
      "buckets": [
        {
          "3": {
            "value": 32.77153188344594
          },
          "key": "Women's Clothing",
          "doc_count": 62,
          "3-bucket": {
            "buckets": [
              {
                "key_as_string": "2019-10-31T14:00:00.000-04:00",
                "key": 1572544800000,
                "doc_count": 1,
                "3-metric": {
                  "value": 59
                }
              },

```

So the field described as "Overall average" is actually the Average price per interval, Averaged across all the intervals. This is potentially misleading, so I would not recommend doing average of average. Maybe average of sum would be a better metric?

---

<div class="post-metadata">

**Author:** ![Amphagory](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/amphagory/32/46127_2.png) [@Amphagory](https://discuss.elastic.co/u/Amphagory)\
**Post date:** [November 1, 2019, 7:09pm UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111/5 "2019-11-01T19:09:20Z")

</div>

Thanks for your suggestion and it might be a good solution, I'll look into it.

I really want that column of showing the date range then, when I print it out, I know what date/time span we are talking about.

---

<div class="post-metadata">

**Author:** ![anelson-edge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anelson-edge/32/52865_2.png) [@anelson-edge](https://discuss.elastic.co/u/anelson-edge)\
**Post date:** [November 4, 2019, 3:29pm UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111/6 "2019-11-04T15:29:44Z")

</div>

If you use visual builder in Kibana instead of data table, you can access the selected time bucket size

---

<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 2, 2019, 3:29pm UTC](https://discuss.elastic.co/t/date-range-value-for-data-table/206111/7 "2019-12-02T15:29:46Z")

</div>

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