# Pie Chart Query Question

**URL:** <https://discuss.elastic.co/t/pie-chart-query-question/279101>\
**Category:** Kibana\
**Created:** [July 19, 2021, 6:16pm UTC](https://discuss.elastic.co/t/pie-chart-query-question/279101 "2021-07-19T18:16:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![JDMurph](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@JDMurph](https://discuss.elastic.co/u/JDMurph)\
**Post date:** [July 19, 2021, 6:16pm UTC](https://discuss.elastic.co/t/pie-chart-query-question/279101/1 "2021-07-19T18:16:02Z")

</div>

Is it possible to do a pie chart that gives the following with the below instance? Sum up the errors per factory and if the error count is equal to 3 or greater it would be classified as "Failing". If it's greater than 1 but less than 3 it's classified as "At-Risk". If it's zero then classified as 'Normal".

The pie chart would look like this 2 "Failing", 1 "At Risk", and 1 "Good".

|factory|error|  
|factory A|1|  
|factory A|1|  
|factory A|1|  
|factory B|0|  
|factory B|1|  
|factory B|1|  
|factory C|0|  
|factory C|0|  
|factory C|0|  
|factory D|1|  
|factory D|1|  
|factory D|1|

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [July 19, 2021, 6:21pm UTC](https://discuss.elastic.co/t/pie-chart-query-question/279101/2 "2021-07-19T18:21:27Z")

</div>

You have two options: either change your data in Elasticsearch, or learn to build a custom Vega visualization. We have [extensive documentation on how to transform you data into an entity-centric format](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html), which is the generic solution to the problem you have described.

There are some limited cases where you can use Vega to calculate your metrics, and I think this might be one of them. You can see our [visualization feature reference](https://www.elastic.co/guide/en/kibana/current/aggregation-reference.html) to compare features, and there's also documentation about how to integrate Vega with your queries.

---

<div class="post-metadata">

**Author:** ![JDMurph](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@JDMurph](https://discuss.elastic.co/u/JDMurph)\
**Post date:** [July 19, 2021, 6:27pm UTC](https://discuss.elastic.co/t/pie-chart-query-question/279101/3 "2021-07-19T18:27:58Z")

</div>

Thank you for the quick reply. I will look more into the Vega resources you linked. I have been trying it in Vega and am struggling with the format.

---

<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:** [August 16, 2021, 6:28pm UTC](https://discuss.elastic.co/t/pie-chart-query-question/279101/4 "2021-08-16T18:28:02Z")

</div>

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