Pie Chart Query Question

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|

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, 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 to compare features, and there's also documentation about how to integrate Vega with your queries.

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.