# Unable to show empty buckets when using Date Histogram on @timestamp field

**URL:** https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238
**Category:** Kibana
**Created:** [July 21, 2021, 8:12am UTC](https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238 "2021-07-21T08:12:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![prathamesh7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathamesh7/32/99920_2.png) [@prathamesh7](https://discuss.elastic.co/u/prathamesh7)
#### Post date: [July 21, 2021, 8:12am UTC](https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238/1 "2021-07-21T08:12:26Z")

</div>

Hi Team,

I am retrieving results of a query for last 7 days in visualisation, but in the response i am not seeing results for empty buckets i.e its not showing any result for that day when there is no data. There is no option to choose as `Show empty buckets`.

In below graph, it shows all the dates of last 7 days (even if its having any result or not) but in response i am only getting dates that are having any result and not all the dates which are having zero results also. How can i change this to get all the dates (irrespective of zero or any result) in response.

 ![Screenshot 2021-07-21 at 1.38.17 PM](https://us1.discourse-cdn.com/elastic/original/3X/e/2/e26c4445ef838cabe48a1bc57cf481bfdd1d6abc.png)

Below is the response - Its not showing 17th, 18th date and 20th date

```auto
  "took": 6,
  "timed_out": false,
  "_shards": {
    "total": 21,
    "successful": 21,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 13,
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "2": {
      "buckets": [
        {
          "key_as_string": "2021-07-15T00:00:00.000+05:30",
          "key": 1626287400000,
          "doc_count": 1
        },
        {
          "key_as_string": "2021-07-16T00:00:00.000+05:30",
          "key": 1626373800000,
          "doc_count": 7
        },
        {
          "key_as_string": "2021-07-19T00:00:00.000+05:30",
          "key": 1626633000000,
          "doc_count": 4
        },
        {
          "key_as_string": "2021-07-21T00:00:00.000+05:30",
          "key": 1626805800000,
          "doc_count": 1
        }
      ]
    }
  },
  "status": 200
}

```

version is 7.4

Thanks,

---

<div class="post-metadata">

### Author: ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)
#### Post date: [July 21, 2021, 9:11am UTC](https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238/2 "2021-07-21T09:11:01Z")

</div>

Try using the below in your advanced JSON input

{ "min\_doc\_count": 0 }

And see if you can get what you wanted.

---

<div class="post-metadata">

### Author: ![prathamesh7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathamesh7/32/99920_2.png) [@prathamesh7](https://discuss.elastic.co/u/prathamesh7)
#### Post date: [July 21, 2021, 9:24am UTC](https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238/3 "2021-07-21T09:24:17Z")

</div>

Hi @Sandeep_Raju, Thanks for your reply.

Yes i have tried this in devtools by changing request as `"min_doc_count": 1` to `"min_doc_count": 0` and getting all seven days results. Thanks.

but same is not working when checking for 24 hrs of a day i.e its not showing all the hrs irrespective of results. only shows hr that has any result. Any idea why?

Thanks,

---

<div class="post-metadata">

### Author: ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)
#### Post date: [July 21, 2021, 9:47am UTC](https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238/4 "2021-07-21T09:47:38Z")

</div>

Can you try to keep minimum interval as auto in date histogram instead of daily and check?

---

<div class="post-metadata">

### Author: ![prathamesh7](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prathamesh7/32/99920_2.png) [@prathamesh7](https://discuss.elastic.co/u/prathamesh7)
#### Post date: [July 21, 2021, 10:32am UTC](https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238/5 "2021-07-21T10:32:00Z")

</div>

Hi @Sandeep_Raju,

I am getting below response as expected for 7 days (i.e In response, getting each date with their whatever results is whether 0 or any number) after changing above `min_doc_count: 0`, this was for 7 days.

```auto
{
          "key_as_string" : "2021-07-15T00:00:00.000+05:30",
          "key" : 1626287400000,
          "doc_count" : 1
        },
        {
          "key_as_string" : "2021-07-16T00:00:00.000+05:30",
          "key" : 1626373800000,
          "doc_count" : 7
        },
        {
          "key_as_string" : "2021-07-17T00:00:00.000+05:30",
          "key" : 1626460200000,
          "doc_count" : 0
        },
        {
          "key_as_string" : "2021-07-18T00:00:00.000+05:30",
          "key" : 1626546600000,
          "doc_count" : 0
        },
        {
          "key_as_string" : "2021-07-19T00:00:00.000+05:30",
          "key" : 1626633000000,
          "doc_count" : 4
        },
        {
          "key_as_string" : "2021-07-20T00:00:00.000+05:30",
          "key" : 1626719400000,
          "doc_count" : 0
        },
        {
          "key_as_string" : "2021-07-21T00:00:00.000+05:30",
          "key" : 1626805800000,
          "doc_count" : 1
        }

```

Now, I am trying to get results of all 24 hrs of a day by changing `timerange` from `Last 7 days` to `Last 24 hours` and minimum interval as `Auto` but it's still not showing for all 24 hrs.

 ![Screenshot 2021-07-21 at 3.54.11 PM](https://us1.discourse-cdn.com/elastic/original/3X/5/6/56b3997e1ca169dc636eb8b8ba1d286e49f1fd0c.png)

Thanks,

---

<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: [August 18, 2021, 10:32am UTC](https://discuss.elastic.co/t/unable-to-show-empty-buckets-when-using-date-histogram-on-timestamp-field/279238/6 "2021-08-18T10:32:19Z")

</div>

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