# Grouping values in graphic

**URL:** https://discuss.elastic.co/t/grouping-values-in-graphic/203534
**Category:** Kibana
**Tags:** elastic-stack-graph
**Created:** [October 14, 2019, 11:22pm UTC](https://discuss.elastic.co/t/grouping-values-in-graphic/203534 "2019-10-14T23:22:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![rolo](https://avatars.discourse-cdn.com/v4/letter/r/82dd89/32.png) [@rolo](https://discuss.elastic.co/u/rolo)
#### Post date: [October 14, 2019, 11:22pm UTC](https://discuss.elastic.co/t/grouping-values-in-graphic/203534/1 "2019-10-14T23:22:41Z")

</div>

hi,

I am trying to create a new visualize by counting values by url in Kibana.

Example:  
[facebok.com/api/home/id\_ramdoms/home\_page](http://facebok.com/api/home/id_ramdoms/home_page)  
[facebok.com/api/home/id\_randoms](http://facebok.com/api/home/id_randoms)

I would like to create a script to create a new field.

Like url\_resource and just see /home\_page and /home.

How can I divide the url?

Thank you very much in advance

---

<div class="post-metadata">

### Author: ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)
#### Post date: [October 17, 2019, 8:18pm UTC](https://discuss.elastic.co/t/grouping-values-in-graphic/203534/2 "2019-10-17T20:18:10Z")

</div>

Maybe something like this would work:

```auto
def url = doc['url'].value;
return url.substring(url.lastIndexOf('/') + 1);

```

See [https://www.elastic.co/blog/using-painless-kibana-scripted-fields](https://www.elastic.co/blog/using-painless-kibana-scripted-fields).

---

<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: [November 14, 2019, 8:18pm UTC](https://discuss.elastic.co/t/grouping-values-in-graphic/203534/3 "2019-11-14T20:18:13Z")

</div>

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