# How to use the .max() in timelion

**URL:** https://discuss.elastic.co/t/how-to-use-the-max-in-timelion/102286
**Category:** Kibana
**Created:** [September 29, 2017, 4:48pm UTC](https://discuss.elastic.co/t/how-to-use-the-max-in-timelion/102286 "2017-09-29T16:48:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://discuss.elastic.co/u/Cristian)
#### Post date: [September 29, 2017, 4:48pm UTC](https://discuss.elastic.co/t/how-to-use-the-max-in-timelion/102286/1 "2017-09-29T16:48:44Z")

</div>

Hi All,  
I use this expression:

Exp1  
`.es(_exists_:candles.highMid, timefield=candles.time,offset=-1d).if(eq, 0, null, .es(timefield=candles.time,offset=-1d,metric=sum:candles.highMid)).fit(average)`

and this expression:

Exp2  
`.es(_exists_:candles.highMid, timefield=candles.time).if(eq, 0, null, .es(timefield=candles.time,metric=sum:candles.highMid)).fit(average)`

But! I would like to plot the highest of these - max(Exp1, Exp2). Is this possible?

Br  
Cris

---

<div class="post-metadata">

### Author: ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)
#### Post date: [October 3, 2017, 1:23am UTC](https://discuss.elastic.co/t/how-to-use-the-max-in-timelion/102286/2 "2017-10-03T01:23:37Z")

</div>

> [@Cristian](#):
>
> .es(_exists_:candles.highMid, timefield=candles.time).if(eq, 0, null, .es(timefield=candles.time,metric=sum:candles.highMid)).fit(average)

Hi there Cris, you can combine and compare your expressions using the `max` function like this:

```auto
.es(_exists_:candles.highMid, timefield=candles.time,offset=-1d).if(eq, 0, null, .es(timefield=candles.time,offset=-1d,metric=sum:candles.highMid)).fit(average).max(
  .es(_exists_:candles.highMid, timefield=candles.time).if(eq, 0, null, .es(timefield=candles.time,metric=sum:candles.highMid)).fit(average)
)

```

Hope this helps!

CJ

---

<div class="post-metadata">

### Author: ![Cristian](https://avatars.discourse-cdn.com/v4/letter/c/a698b9/32.png) [@Cristian](https://discuss.elastic.co/u/Cristian)
#### Post date: [October 6, 2017, 11:39am UTC](https://discuss.elastic.co/t/how-to-use-the-max-in-timelion/102286/3 "2017-10-06T11:39:54Z")

</div>

Thanks! Works fine!.

---

<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: [November 3, 2017, 11:39am UTC](https://discuss.elastic.co/t/how-to-use-the-max-in-timelion/102286/4 "2017-11-03T11:39:59Z")

</div>

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