# Bucket aggregation in Kibana

**URL:** https://discuss.elastic.co/t/bucket-aggregation-in-kibana/64088
**Category:** Elasticsearch
**Created:** [October 27, 2016, 4:16am UTC](https://discuss.elastic.co/t/bucket-aggregation-in-kibana/64088 "2016-10-27T04:16:36Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Mohana01](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mohana01](https://discuss.elastic.co/u/Mohana01)
#### Post date: [October 27, 2016, 4:16am UTC](https://discuss.elastic.co/t/bucket-aggregation-in-kibana/64088/1 "2016-10-27T04:16:36Z")

</div>

Hi all  
I have created the below Elastic search query pipe line aggregation to calculate percentage based on my event data.  
I would like to know how to use this same in Kibana. i want to make the percentage value to get displayed in any of the visualization (Metric,table, etc.,)  
{  
"aggs": {  
"totrecords": {  
"date\_histogram": {  
"field": "@timestamp",  
"interval": "month",  
"format": "yyyy-MM-dd"  
},  
"aggs": {  
"totcount": {  
"value\_count": {  
"field": "@timestamp"  
}  
},  
"num\_record": {  
"filter": {  
"term": {  
"NUM\_RECORDS": "0"  
}  
},  
"aggs": {  
"numcount": {  
"value\_count": {  
"field": "NUM\_RECORDS"  
}  
}  
}

```
        },
        "bmw_percentage": {
                "bucket_script": {
                    "buckets_path": {
                      "numcnt": "num_record>numcount",
                      "totalcnt": "totcount"
                    },
                    "script": " numcnt / totalcnt * 100"
                }
            }
     }
  }

```

}  
}

---

<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 5, 2017, 10:09pm UTC](https://discuss.elastic.co/t/bucket-aggregation-in-kibana/64088/2 "2017-07-05T22:09:13Z")

</div>


