# Moving Average in Timelion

**URL:** https://discuss.elastic.co/t/moving-average-in-timelion/209948
**Category:** Kibana
**Tags:** timelion
**Created:** [November 29, 2019, 9:36am UTC](https://discuss.elastic.co/t/moving-average-in-timelion/209948 "2019-11-29T09:36:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Georg\_Seibt](https://avatars.discourse-cdn.com/v4/letter/g/51bf81/32.png) [@Georg\_Seibt](https://discuss.elastic.co/u/Georg_Seibt)
#### Post date: [November 29, 2019, 9:36am UTC](https://discuss.elastic.co/t/moving-average-in-timelion/209948/1 "2019-11-29T09:36:12Z")

</div>

Hello,  
I am trying to visulaize some more comlex metrics with timelion. I have a value per day (average number of events per user) and I want to know if that number is higher than the moving average of the last 7 days (plus or minus 30% of the moving average: light grey line). The following image shows what I have.

 ![grafik](https://us1.discourse-cdn.com/elastic/original/3X/6/9/69a046d8b88752607b9a9b768f318e9da55964c8.png)

However as you can see, it does not calculate the moving average for the last days... If I would change the window to 2 days, it would also calculate the moving average for the last days, and everything would be perfect.

That's my query:  
.es(q='SOME\_FILTERS').divide(.es(q='SOME\_FILTERS'))  
.mvavg(7d)  
.label("Rolling Average (7)")  
.color('grey'),

Is it a bug? Or am I doing something wrong?

Thanks for your help!  
Georg

---

<div class="post-metadata">

### Author: ![mikecote](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mikecote/32/58549_2.png) [@mikecote](https://discuss.elastic.co/u/mikecote)
#### Post date: [November 29, 2019, 3:14pm UTC](https://discuss.elastic.co/t/moving-average-in-timelion/209948/2 "2019-11-29T15:14:43Z")

</div>

It could be you don't have enough data yet. Can you provide the filters you are using on your data (for .es and .divide)?

---

<div class="post-metadata">

### Author: ![Georg\_Seibt](https://avatars.discourse-cdn.com/v4/letter/g/51bf81/32.png) [@Georg\_Seibt](https://discuss.elastic.co/u/Georg_Seibt)
#### Post date: [December 2, 2019, 7:04am UTC](https://discuss.elastic.co/t/moving-average-in-timelion/209948/3 "2019-12-02T07:04:37Z")

</div>

OK. I was a lttle bit confused. I now understand why the data is not shown and everything is correct. Thanks for the reply, Mike.

---

<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: [December 30, 2019, 7:04am UTC](https://discuss.elastic.co/t/moving-average-in-timelion/209948/4 "2019-12-30T07:04:47Z")

</div>

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