# Average on Kibana Timelion with two values or parameter

**URL:** https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361
**Category:** Kibana
**Tags:** timelion
**Created:** [June 6, 2017, 6:50am UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361 "2017-06-06T06:50:37Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![shreyanshu\_pare](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@shreyanshu\_pare](https://discuss.elastic.co/u/shreyanshu_pare)
#### Post date: [June 6, 2017, 6:50am UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/1 "2017-06-06T06:50:37Z")

</div>

I have json

{ ExchangeName:BITFINEX, CurrencyPair:ETHBTC ,MachineTime:June 5th 2017, 15:59:53.883, BidPrice:0.094 ,BidSize:22.935, AskPrice:0.094 ,AskSize:20.01, LastPrice:0.094 }

In timelion i want to find an average of (BidPrice and AskPrice).

(.es(index=ethbtc\_ticker,timefield=MachineTime,split='ExchangeName:35',metric=avg:BidPrice).plus(.es(index=ethbtc\_ticker,timefield=MachineTime,metric=avg:AskPrice)).label(midpoint,ExchangeName)).divide(divisor=2)

is it correct ? or any other way can we do?

---

<div class="post-metadata">

### Author: ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)
#### Post date: [June 6, 2017, 10:14am UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/2 "2017-06-06T10:14:24Z")

</div>

Hi @shreyanshu_pare,

I'm afraid the query will probably not produce the results you expect. The reason is, that the first `.es()` query is split on the `ExchangeName` field while the second is not. I don't see a way to correctly use `split` `.plus()` at the same time here.

Instead I would suggest to create an index pattern with a [scripted field](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html) that calculates the average for each document using `(doc['BidPrice'].value + doc['AskPrice'].value) / 2` and visualize that in the [Visualize app](https://www.elastic.co/guide/en/kibana/current/xy-chart.html) using the average of the scripted field as a metric aggregation (y-axis) and a date histogram and a terms filter as the bucket aggregations (x-axis).

---

<div class="post-metadata">

### Author: ![shreyanshu\_pare](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@shreyanshu\_pare](https://discuss.elastic.co/u/shreyanshu_pare)
#### Post date: [June 6, 2017, 10:19am UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/3 "2017-06-06T10:19:55Z")

</div>

Hi @weltenwort  
if i am using split in second then it is showing Error:

Timelion: Error: in cell #1: argument must be a seriesList with a single series

if we use .add(), so is it useful ? i want in timelion.

---

<div class="post-metadata">

### Author: ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)
#### Post date: [June 6, 2017, 10:26am UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/4 "2017-06-06T10:26:24Z")

</div>

Right, that is what I meant by

> [@weltenwort](#):
>
> I don't see a way to correctly use split .plus() at the same time here.

Timelion does not seem to be the right tool for this job. That is why I proposed using a scripted field in combination with Visualize.

---

<div class="post-metadata">

### Author: ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)
#### Post date: [June 6, 2017, 10:29am UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/5 "2017-06-06T10:29:55Z")

</div>

If you're using the most recent version of Kibana you might also have success with the [Time Series Visual Builder](https://www.elastic.co/guide/en/kibana/current/time-series-visual-builder.html), which allows for some ad-hoc processing of the data as well.

---

<div class="post-metadata">

### Author: ![shreyanshu\_pare](https://avatars.discourse-cdn.com/v4/letter/s/f4b2a3/32.png) [@shreyanshu\_pare](https://discuss.elastic.co/u/shreyanshu_pare)
#### Post date: [June 6, 2017, 10:31am UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/6 "2017-06-06T10:31:38Z")

</div>

ok ,Thanks @weltenwort , i will check.  
If we use methlion in timelion so it is possible?

---

<div class="post-metadata">

### Author: ![weltenwort](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/weltenwort/32/53885_2.png) [@weltenwort](https://discuss.elastic.co/u/weltenwort)
#### Post date: [June 6, 2017, 1:42pm UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/7 "2017-06-06T13:42:41Z")

</div>

Mathlion is a third-party plugin and as such not officially supported by Elastic, but it might be able to achieve that.

---

<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 4, 2017, 1:42pm UTC](https://discuss.elastic.co/t/average-on-kibana-timelion-with-two-values-or-parameter/88361/8 "2017-07-04T13:42:54Z")

</div>

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