# Mathematic Calculation

**URL:** <https://discuss.elastic.co/t/mathematic-calculation/98406>\
**Category:** Kibana\
**Created:** [August 25, 2017, 6:53pm UTC](https://discuss.elastic.co/t/mathematic-calculation/98406 "2017-08-25T18:53:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit2015](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Amit2015](https://discuss.elastic.co/u/Amit2015)\
**Post date:** [August 25, 2017, 6:53pm UTC](https://discuss.elastic.co/t/mathematic-calculation/98406/1 "2017-08-25T18:53:55Z")

</div>

Hi,

I am trying to create timelion, have 4 fields lets say a,b,c,d. It should perform mathematics calculation like a+b/c+d and it should have one line output.

Any idea how to do it?

Thanks...

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [August 28, 2017, 6:57am UTC](https://discuss.elastic.co/t/mathematic-calculation/98406/2 "2017-08-28T06:57:00Z")

</div>

that should be quite simple, but you have not mentioned how you want to aggregate your fields ...

lets say your data looks like this:

```auto
 date | a | b | c | d
 1.1.2017 12:00 | 1 | 1 | 2 | 1
 1.1.2017 12:45 | 2 | 1 | 2 | 1
 1.1.2017 13:00 | 1 | 1 | 1 | 1
 2.1.2017 12:00 | 1 | 3 | 2 | 1

```

now in timelion you'll be looking at your daily data for example .... how do you want to treat multiple records from the same day ? do you want to look at average, sum, min, max... ?

so lets say you want to do a sum aggregation then your timelion expression would look something like this:

```auto
.es(metric=sum:a).add(.es(metric=sum:b).divide(.es(metric=sum:c).add(metric=sum:d))
```

---

<div class="post-metadata">

**Author:** ![Amit2015](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Amit2015](https://discuss.elastic.co/u/Amit2015)\
**Post date:** [August 29, 2017, 6:55pm UTC](https://discuss.elastic.co/t/mathematic-calculation/98406/5 "2017-08-29T18:55:16Z")

</div>

It works... Thank You!

---

<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:** [September 26, 2017, 6:55pm UTC](https://discuss.elastic.co/t/mathematic-calculation/98406/6 "2017-09-26T18:55:33Z")

</div>

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