# Create complex queries in timelion - divide and substract in one query

**URL:** https://discuss.elastic.co/t/create-complex-queries-in-timelion-divide-and-substract-in-one-query/220879
**Category:** Kibana
**Tags:** timelion
**Created:** [February 25, 2020, 3:17pm UTC](https://discuss.elastic.co/t/create-complex-queries-in-timelion-divide-and-substract-in-one-query/220879 "2020-02-25T15:17:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![little\_squirrel](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@little\_squirrel](https://discuss.elastic.co/u/little_squirrel)
#### Post date: [February 25, 2020, 3:17pm UTC](https://discuss.elastic.co/t/create-complex-queries-in-timelion-divide-and-substract-in-one-query/220879/1 "2020-02-25T15:17:41Z")

</div>

Dear Community,

I would like to know if there is any way to analyze in Kibana the following type of equation: a/(b-c).  
The difference I managed to get in timelion, but my attempt to calculate a.divide(b-c) failed.  
Is this even possible in timelion?

---

<div class="post-metadata">

### Author: ![joshdover](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joshdover/32/42020_2.png) [@joshdover](https://discuss.elastic.co/u/joshdover)
#### Post date: [February 25, 2020, 9:02pm UTC](https://discuss.elastic.co/t/create-complex-queries-in-timelion-divide-and-substract-in-one-query/220879/2 "2020-02-25T21:02:17Z")

</div>

The syntax here should be:

```auto
.es().divide(.es().subtract(.es()))

```

If you can't get that to work, could you post a more complete example of what your query looks like?

---

<div class="post-metadata">

### Author: ![little\_squirrel](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@little\_squirrel](https://discuss.elastic.co/u/little_squirrel)
#### Post date: [February 26, 2020, 5:54pm UTC](https://discuss.elastic.co/t/create-complex-queries-in-timelion-divide-and-substract-in-one-query/220879/3 "2020-02-26T17:54:39Z")

</div>

Thanks for the answer! I have found the error in the query, there was an additional space there. Not this works.

---

<div class="post-metadata">

### Author: ![little\_squirrel](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@little\_squirrel](https://discuss.elastic.co/u/little_squirrel)
#### Post date: [February 27, 2020, 9:28am UTC](https://discuss.elastic.co/t/create-complex-queries-in-timelion-divide-and-substract-in-one-query/220879/4 "2020-02-27T09:28:47Z")

</div>

Now, I have another question related to the same query.

How it will look like if I want to compare the same query for two sensors in the same graph?

---

<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 26, 2020, 9:28am UTC](https://discuss.elastic.co/t/create-complex-queries-in-timelion-divide-and-substract-in-one-query/220879/5 "2020-03-26T09:28:56Z")

</div>

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