# Visualizing Average with Removing Outliers

**URL:** <https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [June 16, 2021, 6:58pm UTC](https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184 "2021-06-16T18:58:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JR42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jr42/32/90421_2.png) [@JR42](https://discuss.elastic.co/u/JR42)\
**Post date:** [June 16, 2021, 6:58pm UTC](https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184/1 "2021-06-16T18:58:41Z")

</div>

Hey all, looking to get some help on a topic that has had me stumped.

I am currently charting the average compile times (which the compile time is a scripted field on the index pattern), bucketed by month using a date histogram using a line chart. However, I want to filter out documents that are outliers (either \>90th percentile or more than two std deviations from the computed average).

I am stumped as to how this would be achieved (if it can be at all currently with basic visualizations). Ideally, I would like to chain aggregate queries, to first aggregate the standard deviation (or percentile) and then use that data to do a filtered average aggregation.

From searching around on the forums, the most similar question I've found is [this post](https://discuss.elastic.co/t/visualization-for-top-90-average/195823) which confirms my doubt of this being possible due to requiring two separate queries. Is this still the case today, is a Vega visualization the only way to feasibly do this?

Thanks!

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [June 17, 2021, 11:17am UTC](https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184/2 "2021-06-17T11:17:52Z")

</div>

Vega is still the recommended solution for that due to the chained queries.

---

<div class="post-metadata">

**Author:** ![JR42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jr42/32/90421_2.png) [@JR42](https://discuss.elastic.co/u/JR42)\
**Post date:** [June 17, 2021, 1:09pm UTC](https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184/3 "2021-06-17T13:09:43Z")

</div>

Thanks for confirming my suspicion! Do you happen to have any example of this being done (or something similar)?

---

<div class="post-metadata">

**Author:** ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)\
**Post date:** [June 17, 2021, 3:53pm UTC](https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184/4 "2021-06-17T15:53:39Z")

</div>

I haven't found a specific one, but I think this might help: [Scale | Vega-Lite](https://vega.github.io/vega-lite/docs/scale.html#example-clipping-or-removing-unwanted-data-points)

---

<div class="post-metadata">

**Author:** ![JR42](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jr42/32/90421_2.png) [@JR42](https://discuss.elastic.co/u/JR42)\
**Post date:** [June 17, 2021, 7:09pm UTC](https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184/5 "2021-06-17T19:09:24Z")

</div>

Awesome, I appreciate all the help Marius!

---

<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:** [July 15, 2021, 7:10pm UTC](https://discuss.elastic.co/t/visualizing-average-with-removing-outliers/276184/6 "2021-07-15T19:10:23Z")

</div>

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