# Histogram to show object count for missing days in date histogram

**URL:** <https://discuss.elastic.co/t/histogram-to-show-object-count-for-missing-days-in-date-histogram/280247>\
**Category:** Kibana\
**Created:** [August 2, 2021, 6:03pm UTC](https://discuss.elastic.co/t/histogram-to-show-object-count-for-missing-days-in-date-histogram/280247 "2021-08-02T18:03:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SUMANT\_MISHRA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumant_mishra/32/77606_2.png) [@SUMANT\_MISHRA](https://discuss.elastic.co/u/SUMANT_MISHRA)\
**Post date:** [August 2, 2021, 6:03pm UTC](https://discuss.elastic.co/t/histogram-to-show-object-count-for-missing-days-in-date-histogram/280247/1 "2021-08-02T18:03:52Z")

</div>

Hi,

I need support in creating a histogram that can show the count of objects on a daily basis if the date (in the histogram) falls within a date range. It should show count of the objects even if there is no object available for any particular date of the date field.For example, date field contains objects for 2nd August, 4th August and 8th August. But histogram should show the object count of the missing dates like 3rd, 5th, 6th and 7th.

**Data structure:**

```auto
{
  "SiteId" : 1,
  "StartDate" : "2021-07-31",
  "EndDate" : "2021-08-04",
  "CreatedAt" : "2021-08-02T23:11:25.84"
}
{
  "SiteId" : 2,
  "StartDate" : "2021-08-03",
  "EndDate" : "2021-08-05",
  "CreatedAt" : "2021-08-04T23:11:25.84"
}
{
  "SiteId" : 3,
  "StartDate" : "2021-08-03",
  "EndDate" : "2021-08-10",
  "CreatedAt" : "2021-08-08T23:11:25.84"
}

```

**Expected output:**

 ![Screenshot 2021-08-02 at 11.26.03 PM](https://us1.discourse-cdn.com/elastic/original/3X/3/7/37b0daa2bf5e1b23554f6042ea1f17f41ecf509c.png)

Appreciate any help in advance.

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [August 3, 2021, 7:04pm UTC](https://discuss.elastic.co/t/histogram-to-show-object-count-for-missing-days-in-date-histogram/280247/2 "2021-08-03T19:04:31Z")

</div>

When creating a histogram in Lens you now have the option to show Empty buckets as well. Just do a split per day for the histogram and a count metric for the objects.

---

<div class="post-metadata">

**Author:** ![SUMANT\_MISHRA](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sumant_mishra/32/77606_2.png) [@SUMANT\_MISHRA](https://discuss.elastic.co/u/SUMANT_MISHRA)\
**Post date:** [August 4, 2021, 6:30pm UTC](https://discuss.elastic.co/t/histogram-to-show-object-count-for-missing-days-in-date-histogram/280247/3 "2021-08-04T18:30:05Z")

</div>

Hi @Marius_Dragomir, the challenge is there how to get the count for empty buckets? I need to get the count if the key\_as\_string value of the dates on histogram falls between StartDate and EndDate. I am trying to get an output like:

```auto
{
  "Date" : "2021-07-31",
  "ActiveCount" : 1,
}
{
  "Date" : "2021-08-01",
  "ActiveCount" : 1,
}
{
  "Date" : "2021-08-2",
  "ActiveCount" : 3,
}
{
  "Date" : "021-08-3",
  "ActiveCount" : 3,
}
{
  "Date" : "021-08-4",
  "ActiveCount" : 2,
}
{
  "Date" : "021-08-5",
  "ActiveCount" : 1,
}
{
  "Date" : "021-08-6",
  "ActiveCount" : 1,
}
{
  "Date" : "021-08-7",
  "ActiveCount" : 1,
}

```

I can also see an open question on stackoverflow related to this:

> <https://stackoverflow.com/questions/33683455/elasticsearch-date-histogram-calculate-histogram-field-from-start-and-stop-da>

---

<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:** [September 1, 2021, 6:30pm UTC](https://discuss.elastic.co/t/histogram-to-show-object-count-for-missing-days-in-date-histogram/280247/4 "2021-09-01T18:30:54Z")

</div>

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