# Chart pie count field

**URL:** https://discuss.elastic.co/t/chart-pie-count-field/112462
**Category:** Kibana
**Created:** [December 19, 2017, 3:27pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462 "2017-12-19T15:27:48Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![radi](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@radi](https://discuss.elastic.co/u/radi)
#### Post date: [December 19, 2017, 3:27pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/1 "2017-12-19T15:27:48Z")

</div>

hello,  
I have a pie of count split terms and I want make addition of some fields of this aggregation  
exemple i have count of (women , men ,child girls, child boy )  
but i have to make pie with count of (women+ child girls) and (men +child boy)

how can i do this please ?

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [December 19, 2017, 3:38pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/2 "2017-12-19T15:38:17Z")

</div>

You would need to reindex your data and add another field like `gender` where you would set it to `female` if the first field is either `women` or `child girls`

you could also do that on-the-fly with [scripted fields](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html), however that will create a much bigger load and might not be appropriate if your dataset is big.

---

<div class="post-metadata">

### Author: ![radi](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@radi](https://discuss.elastic.co/u/radi)
#### Post date: [December 19, 2017, 4:40pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/3 "2017-12-19T16:40:05Z")

</div>

Thank's for your answer can you give me exemple of scripted fileds similaire of my exemple please ?  
in [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)  
there is no exemple similaire to my case !

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [December 19, 2017, 4:44pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/4 "2017-12-19T16:44:13Z")

</div>

something like:

```auto
if (doc['field1'].value == 'women' || doc['field1'].value == 'girls') return 'female';
if (doc['field1'].value == 'men' || doc['field1'].value == 'boys') return 'male';
return 'n/a';

```

---

<div class="post-metadata">

### Author: ![radi](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@radi](https://discuss.elastic.co/u/radi)
#### Post date: [December 20, 2017, 10:44am UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/5 "2017-12-20T10:44:55Z")

</div>

hi,  
my script filed work very good in visualize but when i call it in dashboard i have Error  
"Could not locate that index-pattern-field (id: mynewscriptsfiledadd)"!

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [December 20, 2017, 12:57pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/6 "2017-12-20T12:57:42Z")

</div>

that's weird ... should not happen i think.

could you open an issue on [http://github.com/elastic/kibana](http://github.com/elastic/kibana) ?

---

<div class="post-metadata">

### Author: ![radi](https://avatars.discourse-cdn.com/v4/letter/r/4491bb/32.png) [@radi](https://discuss.elastic.co/u/radi)
#### Post date: [December 20, 2017, 3:01pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/7 "2017-12-20T15:01:25Z")

</div>

Yes, you are right it's should not happen , in my cas it's  
Mishandling

thank's for your replay

---

<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: [January 17, 2018, 3:16pm UTC](https://discuss.elastic.co/t/chart-pie-count-field/112462/9 "2018-01-17T15:16:49Z")

</div>

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