# Remove empty data buckets with @timestan

**URL:** <https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452>\
**Category:** Kibana\
**Created:** [May 24, 2022, 6:12am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452 "2022-05-24T06:12:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rashmi\_Prabha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi_prabha/32/106068_2.png) [@Rashmi\_Prabha](https://discuss.elastic.co/u/Rashmi_Prabha)\
**Post date:** [May 24, 2022, 6:12am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/1 "2022-05-24T06:12:49Z")

</div>

![WhatsApp Image 2022-05-24 at 10.32.21 AM](https://us1.discourse-cdn.com/elastic/original/3X/b/c/bc9873d0dbe4df5e79beb8213a02a4d86095f4dd.jpeg)  
How to remove empty data buckets `{ "min_doc_count":1}` didn't work.

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [May 24, 2022, 7:56am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/2 "2022-05-24T07:56:13Z")

</div>

As I understand correctly, for your case presented on the screenshot you wouldn't like to display months from Jul to Dec because they are empty? Unfortunately the chart you're using is a Date histogram and it is impossible to do that over time.

---

<div class="post-metadata">

**Author:** ![Rashmi\_Prabha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi_prabha/32/106068_2.png) [@Rashmi\_Prabha](https://discuss.elastic.co/u/Rashmi_Prabha)\
**Post date:** [May 24, 2022, 8:45am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/3 "2022-05-24T08:45:15Z")

</div>

any other solution instead of a Date histogram? I split data using some filters and I want to show it according to Months.

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [May 25, 2022, 10:56am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/4 "2022-05-25T10:56:07Z")

</div>

There's one hacky workaround that could work, but it comes with their own set of problems.

1. Create a scripted field based on your timefield `month_of_the_year`  

2. use 'terms' aggregation instead of date histogram.  

The limitations are that the months will not be sorted by 'jan, feb, etc' but only by ascending or descending value. Also, the months across multiple years would be grouped together.

---

<div class="post-metadata">

**Author:** ![Rashmi\_Prabha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi_prabha/32/106068_2.png) [@Rashmi\_Prabha](https://discuss.elastic.co/u/Rashmi_Prabha)\
**Post date:** [May 27, 2022, 5:02am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/5 "2022-05-27T05:02:24Z")

</div>

Thanks for the solution.. unfortunately, this didn't work..

---

<div class="post-metadata">

**Author:** ![Marta\_Bondyra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marta_bondyra/32/102122_2.png) [@Marta\_Bondyra](https://discuss.elastic.co/u/Marta_Bondyra)\
**Post date:** [May 30, 2022, 7:11am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/6 "2022-05-30T07:11:12Z")

</div>

Hmmm, could you paste your configuration screenshot here? Does scripted field return the correct value?

---

<div class="post-metadata">

**Author:** ![Rashmi\_Prabha](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rashmi_prabha/32/106068_2.png) [@Rashmi\_Prabha](https://discuss.elastic.co/u/Rashmi_Prabha)\
**Post date:** [June 15, 2022, 3:59am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/7 "2022-06-15T03:59:04Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/5/4/5494457d91ea6aa04cb6d63612e0294e6b10d6fc.png)  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/c/6/c688bf864efa6c3e32be25adb9af727de93d050d.png)  
Data is correct..  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/9/1/91827acabc90eeb40deb7f63178578b794aba14b.png)

---

<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:** [July 13, 2022, 3:59am UTC](https://discuss.elastic.co/t/remove-empty-data-buckets-with-timestan/305452/8 "2022-07-13T03:59:05Z")

</div>

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