# Pie chart with list

**URL:** <https://discuss.elastic.co/t/pie-chart-with-list/294342>\
**Category:** Kibana\
**Created:** [January 13, 2022, 11:45pm UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342 "2022-01-13T23:45:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cris/32/101855_2.png) [@cris](https://discuss.elastic.co/u/cris)\
**Post date:** [January 13, 2022, 11:45pm UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/1 "2022-01-13T23:45:10Z")

</div>

Hi my friends I'm very new on kibana. I want to create a pie chart with a field who contains a list, like this:

```auto
[passed, passed, passed, passed, failed, failed, failed, passed, passed, passed, passed, passed, passed, passed, failed, passed, passed, failed, passed, passed, passed, passed, passed, passed]

```

When I create the pie chart I get a 50/50 percentage that is wrong because in this hit on this field there are 19 passed and 5 failed like the list above. I am slice by the field that contains the list and size by count of record. I am not sure what I am doing wrong. Please help.

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 14, 2022, 2:16am UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/2 "2022-01-14T02:16:25Z")

</div>

To solve the problem, there should be a little more detail, such as document mappings, number of "test result" per document, pie chart settings...etc.

---

<div class="post-metadata">

**Author:** ![cris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cris/32/101855_2.png) [@cris](https://discuss.elastic.co/u/cris)\
**Post date:** [January 14, 2022, 11:58pm UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/3 "2022-01-14T23:58:07Z")

</div>

Hi I was trying to edit but is not possible.

Hi my friends I'm very new on kibana. I want to create a pie chart with a field who contains a list, like this:  
(Login List Status)

 ![Captura de Pantalla 2022-01-13 a la(s) 20.10.09](https://us1.discourse-cdn.com/elastic/original/3X/7/8/78ebf4cf94e107c3f06e823ff00d30c1d0a4aa69.png)

This field is a script field where I add the keywords from other field, this is my original json doc:

```auto
{
  "ENVA": {
    "Login": {
      "status": "passed"
    }
  },
  "ENVB": {
    "Login": {
      "status": "passed"
    }
  },
  "ENVC": {
    "Login": {
      "status": "passed"
    }
  },
  "ENVD": {
    "Login": {
      "status": "failed"
    }
  }
}

```

and this is the script field "Login List Status":

 ![Captura de Pantalla 2022-01-14 a la(s) 17.56.07](https://us1.discourse-cdn.com/elastic/original/3X/f/c/fc808deddc612ad72bccc035bc611dbbba8b7111.png)

```auto
List l = new ArrayList();

  l.add(doc['ENVA.Login.status.keyword'].value);
  l.add(doc['ENVB.Login.status.keyword'].value);
  l.add(doc['ENVC.Login.status.keyword'].value);
  l.add(doc['ENVD.Login.status.keyword'].value);
  
return l;

```

When I create the pie chart I get a 50/50 percentage that is wrong because in this hit on this field there are 23 passed and 1 failed like the list above.

 ![Captura de Pantalla 2022-01-13 a la(s) 20.14.59](https://us1.discourse-cdn.com/elastic/original/3X/8/1/81978062dbaadd1e18083931d8242bb67c85fda9.png)

I am slice by the field that contains the list and size by count of record. I am not sure what I am doing wrong. Please help.

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 15, 2022, 1:01am UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/4 "2022-01-15T01:01:29Z")

</div>

the pie chart is for a single document (identified by id or something) or aggregation of multiple documents?

Terms aggregation count documents. It count the document with 23 passed and one failed as one document for passed and one document for failed. This is the reason for that 50/50 pie chart.

---

<div class="post-metadata">

**Author:** ![cris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cris/32/101855_2.png) [@cris](https://discuss.elastic.co/u/cris)\
**Post date:** [January 15, 2022, 2:36am UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/5 "2022-01-15T02:36:40Z")

</div>

Thanks for the answer! Is very helpulf for me.

The pie chart is for multiple documents to count how many passed and failed status are in each document.

Sorry I am very new with kibana.

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 15, 2022, 11:34am UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/6 "2022-01-15T11:34:10Z")

</div>

I see, but it is not straight-forward but a difficult problem with elasticsearch.

> [@Count of value in array field](https://discuss.elastic.co/t/count-of-value-in-array-field/207302):
>
> Based on this post "[https://discuss.elastic.co/t/count-of-values-on-array-field-on-visualization/72501](https://discuss.elastic.co/t/count-of-values-on-array-field-on-visualization/72501)" which is posted since Jan 2017 Do we able to do it with the current Kibana (7.x)?

So you have to take alternatives with some compromise. There are several approaches that are quite different.

As far as I can think of, there are

1. use logstash split filter plugin to create a new index with new atomic document.  
eg  
{"ENV": "A", "Login": {"status": "passed"}}  
{"ENV": "B", "Login": {"status": "passed"}}  
{"ENV": "C", "Login": {"status": "passed"}} ...  
This is the structure of documents that kibana is good at, and you can realize various visualizations relatively freely.

2. create script fields of counting each 'pass' and 'fail' values in LoginListStatus and use "Bar vertical percentage" visualization of lens.

---

<div class="post-metadata">

**Author:** ![cris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cris/32/101855_2.png) [@cris](https://discuss.elastic.co/u/cris)\
**Post date:** [January 17, 2022, 4:39pm UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/7 "2022-01-17T16:39:22Z")

</div>

Thanks a lot!!! Thanks for you time and your answers were very useful

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [January 17, 2022, 5:23pm UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/8 "2022-01-17T17:23:18Z")

</div>

Hi @cris,

If you click the "Inspect" button on the top right on that chart editor, you should see a table with the data underneath the visualization. What values are expressed there?

Also, in the same panel you can switch from table view to request view to get the actual query sent to the server to compute the table. Can you share that (removing sensitive information)?

---

<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:** [February 14, 2022, 5:24pm UTC](https://discuss.elastic.co/t/pie-chart-with-list/294342/9 "2022-02-14T17:24:05Z")

</div>

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