# Drop empty buckets

**URL:** <https://discuss.elastic.co/t/drop-empty-buckets/244231>\
**Category:** Kibana\
**Tags:** transforms\
**Created:** [August 8, 2020, 1:05am UTC](https://discuss.elastic.co/t/drop-empty-buckets/244231 "2020-08-08T01:05:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferdous\_Khan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ferdous_khan/32/49396_2.png) [@Ferdous\_Khan](https://discuss.elastic.co/u/Ferdous_Khan)\
**Post date:** [August 8, 2020, 1:05am UTC](https://discuss.elastic.co/t/drop-empty-buckets/244231/1 "2020-08-08T01:05:05Z")

</div>

Hello,

I have data table like below. I am looking for a vertical bar chart that will display sum(elapsed\_time) per week having min(sequence) of that respective week. Final table will have those asterisk highlighted rows i.e. sequence number 101, 108.

```auto
 Week# Day Seq. JobID Elapsed time    
 2020-25 Sun 101 J1* 10    
 2020-25 Sun 101 J1* 5    
 2020-25 Sun 101 J2* 5    
 2020-25 Mon 101 J3* 20    
 2020-25 Mon 102 J1 …    
 2020-25 Mon 101 J2 …    
 2020-25 Tue 103 J1 …    
 … … … … …    
 2020-26 Sun 108 J1* …    
 … … … …    

```

DSL query is similar to this:

```auto
      "aggregations": {
         "week_of_year": {
            "terms": { "field": "week_of_year" },
          "aggregations": {
             "job_name.keyword": {
               "terms": { "field": "job_name.keyword" },
               "aggregations": {
                 "sequence.min": { 
                   "min": { "field": "sequence" }
                 }
               }
             }
          }
        }
      }    

```

When I try to display that on bar chart, I get lot of empty 'sequence' buckets.

I couldn't find a way to do min(sequence) on bar chart and the reason I am doing split chart instead of split series for sequence field is because I want to have legend like Job1, Job2 not like Seq1 - Job1, Seq2 - Job1 etc.

I am wondering whether it's possible to do that on Kibana, dropping those empty buckets

I also tried transform wizard thinking to transfer data to new index removing those empty buckets but it didn't accept my nested aggregation citing duplicated "week\_of\_year" issue

Thanks,  
Ferdous

 ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/9/0/90ffa3061e3f3b43d7582b4ba9af9dcaa2b6c457.jpeg)  
 ![Capture-2](https://us1.discourse-cdn.com/elastic/original/3X/0/c/0cddac575df30aaab616ce350a5bff8d60373806.jpeg)

---

<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:** [August 12, 2020, 5:01pm UTC](https://discuss.elastic.co/t/drop-empty-buckets/244231/2 "2020-08-12T17:01:28Z")

</div>

If you use a histogram aggregation instead of a terms aggregation then there is a an option to drop empty buckets

 ![Screen Shot 2020-08-12 at 11.00.14 AM](https://us1.discourse-cdn.com/elastic/original/3X/9/6/9657076b21d0186f27fffe4c760970a20ea4f3f4.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:** [September 9, 2020, 5:01pm UTC](https://discuss.elastic.co/t/drop-empty-buckets/244231/3 "2020-09-09T17:01:31Z")

</div>

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