# If statement in timelion

**URL:** https://discuss.elastic.co/t/if-statement-in-timelion/110795
**Category:** Kibana
**Tags:** timelion
**Created:** [December 8, 2017, 7:16am UTC](https://discuss.elastic.co/t/if-statement-in-timelion/110795 "2017-12-08T07:16:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kumpelblase](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kumpelblase/32/35709_2.png) [@kumpelblase](https://discuss.elastic.co/u/kumpelblase)
#### Post date: [December 8, 2017, 7:16am UTC](https://discuss.elastic.co/t/if-statement-in-timelion/110795/1 "2017-12-08T07:16:49Z")

</div>

Is it possible to exclude a document based on a value in a field?  
In my case, I want to count the ammount of errors, but only if the field 'status' is not set to 3 (Range from 1 to 6).  
I have found tahe blog about if's in Timelion [https://www.elastic.co/blog/timeseries-if-then-else-with-timelion?baymax=rtp&storm=recommendation&elektra=blog&iesrc=rcmd&astid=8e0aef24-80c1-423b-87a9-f591a5514e99&at=16&rcmd\_source=WIDGET&req\_id=2cda7599-aa3f-4e7f-9541-627416df87e9](https://www.elastic.co/blog/timeseries-if-then-else-with-timelion?baymax=rtp&storm=recommendation&elektra=blog&iesrc=rcmd&astid=8e0aef24-80c1-423b-87a9-f591a5514e99&at=16&rcmd_source=WIDGET&req_id=2cda7599-aa3f-4e7f-9541-627416df87e9). Unfortunately it didn't helped me.

---

<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: [December 8, 2017, 10:22pm UTC](https://discuss.elastic.co/t/if-statement-in-timelion/110795/2 "2017-12-08T22:22:21Z")

</div>

Hi there,

You need to add a filter to the query Timelion uses to retrieve documents for visualizing. In your use case, your filter will exclude any document which has a value of 3 for its "status" field. You can do this like so:

```auto
.es(q='!status:3')

```

See [this related thread](https://discuss.elastic.co/t/timelion-filtering-within-query-and-choosing-different-indexes-as-a-source/48705/2Z) for more info.

Hope this helps,  
CJ

---

<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: [January 5, 2018, 10:22pm UTC](https://discuss.elastic.co/t/if-statement-in-timelion/110795/3 "2018-01-05T22:22:22Z")

</div>

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