# Timelion graph - average with a condition

**URL:** https://discuss.elastic.co/t/timelion-graph-average-with-a-condition/219728
**Category:** Kibana
**Tags:** timelion
**Created:** [February 18, 2020, 7:46am UTC](https://discuss.elastic.co/t/timelion-graph-average-with-a-condition/219728 "2020-02-18T07:46:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gash25](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gash25/32/62851_2.png) [@gash25](https://discuss.elastic.co/u/gash25)
#### Post date: [February 18, 2020, 7:46am UTC](https://discuss.elastic.co/t/timelion-graph-average-with-a-condition/219728/1 "2020-02-18T07:46:17Z")

</div>

Hi,  
i am trying to create a graph in timelion that shows the average value of a field as long as the field is greater than 0.  
For some reason i cannot do that.  
writing the following command returns all points on the 0 graph scale: See TLQuery1.JPG  
.es(index=eu-multitenant-01\*,q='d.Elapsed \> 0',metric=avg:d.Elapsed)

when i change it to the following: .es(index=eu-multitenant-01\*,metric=avg:d.Elapsed) it works fine but the values take into consideration also the 0 amounts which is not what i need. See TLQuery2.JPG

also writing the following command works: .es(index=eu-multitenant-01\*,q='d.Elapsed \> 0') - but again this return the count of rows where Elapsed is greater than 0 - not what i need. See TLQuery3.JPG

 ![TLQuery3](https://us1.discourse-cdn.com/elastic/original/3X/f/4/f426d7400248b65600e384718fb8274b7f4d8d74.jpeg)  
 ![TLQuery2](https://us1.discourse-cdn.com/elastic/original/3X/a/9/a9ed197a10ee408cd71d37fa2ec6bc7736d26773.jpeg)  
 ![TLQuery1](https://us1.discourse-cdn.com/elastic/original/3X/b/3/b3928c1358cd7d8c47e1266d7ef099a83d8cb621.jpeg)

---

<div class="post-metadata">

### Author: ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)
#### Post date: [February 18, 2020, 9:07am UTC](https://discuss.elastic.co/t/timelion-graph-average-with-a-condition/219728/2 "2020-02-18T09:07:22Z")

</div>

The `q` parameter of the `es` function takes a lucene query. AFAIK there is no `>` operator in lucene ([https://lucene.apache.org/core/2\_9\_4/queryparsersyntax.html](https://lucene.apache.org/core/2_9_4/queryparsersyntax.html)), your query is probably searching for the `0` values in your data (which naturally returns a very low average).

Try the `-` operator instead to exclude things: `-d.Elapsed:0`

---

<div class="post-metadata">

### Author: ![gash25](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gash25/32/62851_2.png) [@gash25](https://discuss.elastic.co/u/gash25)
#### Post date: [February 19, 2020, 9:53am UTC](https://discuss.elastic.co/t/timelion-graph-average-with-a-condition/219728/3 "2020-02-19T09:53:08Z")

</div>

Thank for you very much - it works.

---

<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: [March 18, 2020, 9:53am UTC](https://discuss.elastic.co/t/timelion-graph-average-with-a-condition/219728/4 "2020-03-18T09:53:11Z")

</div>

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