# Add average value of data in existing chart elasticsearch kibana

**URL:** <https://discuss.elastic.co/t/add-average-value-of-data-in-existing-chart-elasticsearch-kibana/115605>\
**Category:** Kibana\
**Created:** [January 15, 2018, 9:38pm UTC](https://discuss.elastic.co/t/add-average-value-of-data-in-existing-chart-elasticsearch-kibana/115605 "2018-01-15T21:38:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EditAxha](https://avatars.discourse-cdn.com/v4/letter/e/5f9b8f/32.png) [@EditAxha](https://discuss.elastic.co/u/EditAxha)\
**Post date:** [January 15, 2018, 9:38pm UTC](https://discuss.elastic.co/t/add-average-value-of-data-in-existing-chart-elasticsearch-kibana/115605/1 "2018-01-15T21:38:53Z")

</div>

I have a project in Kibana integrated with elastic search. In Kibana page I am displaying a chart with X(months) and Y(Euro) values.

I want to show a line in the chart that will show the average Euro value of all data.

For the moment I add a manual value to show the horizontal line in the chart. ![Capture](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bd7079a4c3991b2233131ac52c3c34aed49d862c.PNG)

I want to get average value automatically from my data in elastic search. Is there any option to do this task?

Thank you

---

<div class="post-metadata">

**Author:** ![spalger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spalger/32/14092_2.png) [@spalger](https://discuss.elastic.co/u/spalger)\
**Post date:** [January 16, 2018, 8:51pm UTC](https://discuss.elastic.co/t/add-average-value-of-data-in-existing-chart-elasticsearch-kibana/115605/2 "2018-01-16T20:51:13Z")

</div>

Timelion will let you do this because it supports pulling data from multiple sources. Define two series in the timelion expression panel like this: `.es(index=newdata*, metric=avg:euro).color(purple), .es(index=alldata*, metric=avg:euro).color(green)`. You'll want to update the `index=` parameter to match how your data is stored in elasticsearch and checkout the inline documentation for information about other parameters. Then you can use the `interval` picker by the play button to switch to 1m. Timelion visualizations can be saved and used on a dashboard like other visualizations.

---

<div class="post-metadata">

**Author:** ![EditAxha](https://avatars.discourse-cdn.com/v4/letter/e/5f9b8f/32.png) [@EditAxha](https://discuss.elastic.co/u/EditAxha)\
**Post date:** [January 17, 2018, 9:06am UTC](https://discuss.elastic.co/t/add-average-value-of-data-in-existing-chart-elasticsearch-kibana/115605/3 "2018-01-17T09:06:18Z")

</div>

Thank you for your answer but to be clear,

What i want is: when the dataset is loaded to Elasticsearch i want it to calculate automatically the average of the field Euro and save it to a new field. So even when i change the data or add new ones to the Euro field, the avg(Euro) i want it to be automatic function and i can work with this new average in visualization.  
Having automatic calculated average saved in a field must be easier to work with visualization. I think this is the best way to work with it but don't know how to do it.

---

<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, 2018, 9:06am UTC](https://discuss.elastic.co/t/add-average-value-of-data-in-existing-chart-elasticsearch-kibana/115605/4 "2018-02-14T09:06:20Z")

</div>

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