# Display timelion aggregation result as single number

**URL:** <https://discuss.elastic.co/t/display-timelion-aggregation-result-as-single-number/160644>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [December 13, 2018, 1:09am UTC](https://discuss.elastic.co/t/display-timelion-aggregation-result-as-single-number/160644 "2018-12-13T01:09:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![artur.nalbandian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/artur.nalbandian/32/38763_2.png) [@artur.nalbandian](https://discuss.elastic.co/u/artur.nalbandian)\
**Post date:** [December 13, 2018, 1:09am UTC](https://discuss.elastic.co/t/display-timelion-aggregation-result-as-single-number/160644/1 "2018-12-13T01:09:38Z")

</div>

Hi,  
Hopefully you can help me with this question I have about visualizing timelion calculation result.  
Let's say there is a command **A** that runs and takes certain time to run. Later command **B** was introduced that does the same thing but faster. For each command I post into elastic search document with `duration` and `command` fields. What I want to accomplish is to display amount of time saved by introducing command **B** , given that **A** and **B** will be used in parallel for some time.  
It looks like that in order to calculate this I have to do:  
`(AvgA - AvgB) * CountB`  
Where  
`AvgA` - is average duration of command **A**  
`AvgB` - is average duration of command **B**  
`CountB` - count of home many times command **B** were ran.

So I came up with this timelion script to calculate it

```auto
$A = 'command:"A"',
$B = 'command:"B"',
$ACount = .es(index='index', q=$A, metric=count).aggregate(sum),
$BCount = .es(index='index', q=$B, metric=count).aggregate(sum),
.es(index='index', q=$A, metric=sum:duration).aggregate(sum)
 .divide($ACount)
.subtract(
 .es(index='index', q=$B, metric=sum:duration).aggregate(sum)
 .divide($BCount))
.multiply($BCount)

```

As a result of this I'm getting graph with steady horizontal line where Y axis represents result of this calculation. What I would want is to show this in form of a number instead. It looks like timelion has `.bars()` and `.points()` which will represent it in form of bars or points. It doesn't seem like there is a way to represent this in form of a number.  
The other question I have. Is there a way to do this calculation that I'm doing in `metric` field, so that I can draw graph where X axis will be time and Y axis will be result of this aggregation for the specified aggregation interval. So that, this way I can build cumulative graph for example.

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [December 19, 2018, 9:24pm UTC](https://discuss.elastic.co/t/display-timelion-aggregation-result-as-single-number/160644/2 "2018-12-19T21:24:12Z")

</div>

@alexf can you please grab this question?

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![artur.nalbandian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/artur.nalbandian/32/38763_2.png) [@artur.nalbandian](https://discuss.elastic.co/u/artur.nalbandian)\
**Post date:** [January 14, 2019, 6:37pm UTC](https://discuss.elastic.co/t/display-timelion-aggregation-result-as-single-number/160644/3 "2019-01-14T18:37:54Z")

</div>

Hi,

Can you please take a look at this.

Thanks!

---

<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 11, 2019, 6:38pm UTC](https://discuss.elastic.co/t/display-timelion-aggregation-result-as-single-number/160644/4 "2019-02-11T18:38:02Z")

</div>

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