# Create scripted field count total

**URL:** <https://discuss.elastic.co/t/create-scripted-field-count-total/241573>\
**Category:** Kibana\
**Tags:** kql-kibana-query-language\
**Created:** [July 17, 2020, 3:21am UTC](https://discuss.elastic.co/t/create-scripted-field-count-total/241573 "2020-07-17T03:21:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![whyptrap](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whyptrap/32/70605_2.png) [@whyptrap](https://discuss.elastic.co/u/whyptrap)\
**Post date:** [July 17, 2020, 3:21am UTC](https://discuss.elastic.co/t/create-scripted-field-count-total/241573/1 "2020-07-17T03:21:09Z")

</div>

I have field called "My Name", there's available same value for example :  
[1] Smith  
[2] Jason  
[3] Pedro  
[4] Rossi  
[5] James  
[6] Smith  
[7] Jason  
[8] James

In kibana (scripted field), how can i count the same document (not specific using where clause) that the result i want just like :

- Smith = 2
- Jason = 2
- Pedro = 1
- Rossi = 1
- James = 2

I know that the operation can use visualisation to count same doc value, but i want to create scripted field so i can get sum total value of "My Name" where having count more than 1.  
And the final result is : 6 (hope anyone can understand).

Can somebody help?

---

<div class="post-metadata">

**Author:** ![matw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matw/32/13913_2.png) [@matw](https://discuss.elastic.co/u/matw)\
**Post date:** [August 5, 2020, 6:22am UTC](https://discuss.elastic.co/t/create-scripted-field-count-total/241573/2 "2020-08-05T06:22:47Z")

</div>

Hi  
You can't do this with scripted fields, but you can do this using Canvas in Kibana, have a look, here's something similar using our ecommerce demo data:

 ![Bildschirmfoto 2020-08-05 um 08.21.17](https://us1.discourse-cdn.com/elastic/original/3X/3/f/3f6dcdc8efc2f96f6bf0e98585df6f494a44ec6b.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 2, 2020, 6:22am UTC](https://discuss.elastic.co/t/create-scripted-field-count-total/241573/3 "2020-09-02T06:22:55Z")

</div>

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