# Timelion condtion function example

**URL:** https://discuss.elastic.co/t/timelion-condtion-function-example/55987
**Category:** Kibana
**Tags:** timelion
**Created:** [July 20, 2016, 1:43pm UTC](https://discuss.elastic.co/t/timelion-condtion-function-example/55987 "2016-07-20T13:43:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Jeremy\_Colton](https://avatars.discourse-cdn.com/v4/letter/j/51bf81/32.png) [@Jeremy\_Colton](https://discuss.elastic.co/u/Jeremy_Colton)
#### Post date: [July 20, 2016, 1:43pm UTC](https://discuss.elastic.co/t/timelion-condtion-function-example/55987/1 "2016-07-20T13:43:02Z")

</div>

Hi,

I have built this TimeLion query that works:

.es('PID:123 AND event:"Button%20Clicked"').divide(.es('PID:123 AND event:\*')).multiply(100).lines().label('Rate as %')

But sometimes there are no values to plot, so TimeLion draws nothing leaving an empty gap in the line graph.

![](https://us1.discourse-cdn.com/elastic/original/2X/0/03986236f3058206570d47631e41b2253ad4ef41.JPG)

I tried using the fit('none') function but it didn't draw a direct line between the surrounding data points. Instead it plateaued the data which is incorrect:

.es('PID:fashionseoul AND event:"Trendi%20Button%20Clicked"').divide(.es('PID:fashionseoul AND event:\*')).multiply(100).lines().fit('none').label('Rate as %').legend('ne')

![](https://us1.discourse-cdn.com/elastic/original/2X/5/5bb34332f07ffa3a453057fbbc23f95f81bae8a4.JPG)

So I saw there is a condtion() function that may help. How do I use this function such that if a data point is null, to set it to 0 (zero) ?

Many thanks.

---

<div class="post-metadata">

### Author: ![mbertani](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mbertani/32/11398_2.png) [@mbertani](https://discuss.elastic.co/u/mbertani)
#### Post date: [August 16, 2016, 9:37am UTC](https://discuss.elastic.co/t/timelion-condtion-function-example/55987/2 "2016-08-16T09:37:44Z")

</div>

There is an example on using condition at the bottom here: [https://github.com/elastic/timelion/pull/78](https://github.com/elastic/timelion/pull/78)

But you probably just need an if?

.es('PID:123 AND event:"Button%20Clicked"').divide(.es('PID:123 AND event:\*'))**.if(eq, null, 0)**.multiply(100).lines().label('Rate as %')

---

<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 6, 2017, 1:41pm UTC](https://discuss.elastic.co/t/timelion-condtion-function-example/55987/3 "2017-07-06T13:41:04Z")

</div>


