# Kibana - Group by zipcode

**URL:** <https://discuss.elastic.co/t/kibana-group-by-zipcode/170728>\
**Category:** Kibana\
**Created:** [March 4, 2019, 1:46pm UTC](https://discuss.elastic.co/t/kibana-group-by-zipcode/170728 "2019-03-04T13:46:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ragnar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ragnar/32/7610_2.png) [@Ragnar](https://discuss.elastic.co/u/Ragnar)\
**Post date:** [March 4, 2019, 1:46pm UTC](https://discuss.elastic.co/t/kibana-group-by-zipcode/170728/1 "2019-03-04T13:46:39Z")

</div>

I have a classical user index with there address. I wanted to to a visualisation (text, histogram) with the count of each area (aka group zip\_code like 75\*). I can only have visualization of the count of each unique zip code. I want to regroup 75000 with 75100 with... and have the final count for this area.

---

<div class="post-metadata">

**Author:** ![tylersmalley](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tylersmalley/32/8833_2.png) [@tylersmalley](https://discuss.elastic.co/u/tylersmalley)\
**Post date:** [March 5, 2019, 3:09am UTC](https://discuss.elastic.co/t/kibana-group-by-zipcode/170728/2 "2019-03-05T03:09:42Z")

</div>

Just so I understand this right, you're looking to not use the exact zip code, but want it to be a subset and group on that?

If so, I would recommend using a scripted field, and aggregate on that. You can create the scripted field under `Management > Index Patterns`

---

<div class="post-metadata">

**Author:** ![Ragnar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ragnar/32/7610_2.png) [@Ragnar](https://discuss.elastic.co/u/Ragnar)\
**Post date:** [March 5, 2019, 8:09am UTC](https://discuss.elastic.co/t/kibana-group-by-zipcode/170728/3 "2019-03-05T08:09:57Z")

</div>

Yes @tylersmalley,

The zip code here is 5 numbers, only the first two are the "department". I want to know how many customers I have in Paris area (75xxx).  
The scripted field seems to be the right way to do it. I don't get hoe I will do that yet since the regex seems to be off by default.

---

<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:** [April 2, 2019, 8:09am UTC](https://discuss.elastic.co/t/kibana-group-by-zipcode/170728/4 "2019-04-02T08:09:58Z")

</div>

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