# Histogram aggregation?

**URL:** <https://discuss.elastic.co/t/histogram-aggregation/56122>\
**Category:** Kibana\
**Created:** [July 21, 2016, 5:11pm UTC](https://discuss.elastic.co/t/histogram-aggregation/56122 "2016-07-21T17:11:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Suh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/steve_suh/32/10638_2.png) [@Steve\_Suh](https://discuss.elastic.co/u/Steve_Suh)\
**Post date:** [July 21, 2016, 5:11pm UTC](https://discuss.elastic.co/t/histogram-aggregation/56122/1 "2016-07-21T17:11:53Z")

</div>

Hi,  
I have a phone number as one of my fields. Is it possible to bucket by the area code? Do I have to make that a separate field in the document ahead of time or can I calculate the area code from the phone number field and make that the bucket.

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [July 21, 2016, 7:07pm UTC](https://discuss.elastic.co/t/histogram-aggregation/56122/2 "2016-07-21T19:07:48Z")

</div>

Hi Steve,  
I'm pretty sure you would have to make that a separate field in the documents.

The only exception way I could think of without that, is if the phone number were a number data type you could possibly create a scripted field named `area_code` with a script like `doc['phone_number'].value / 10000000`. That might possibly truncate the number to just the first 3 digits. But phone numbers often are string types and scripted fields only work on numbers.

Regards,  
Lee

---

<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 6, 2017, 1:44pm UTC](https://discuss.elastic.co/t/histogram-aggregation/56122/3 "2017-07-06T13:44:52Z")

</div>


