# How to calculate % growth for a sliding time window with a yearly offset?

**URL:** <https://discuss.elastic.co/t/how-to-calculate-growth-for-a-sliding-time-window-with-a-yearly-offset/312880>\
**Category:** Kibana\
**Tags:** timelion\
**Created:** [August 25, 2022, 7:58am UTC](https://discuss.elastic.co/t/how-to-calculate-growth-for-a-sliding-time-window-with-a-yearly-offset/312880 "2022-08-25T07:58:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tastyminerals](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tastyminerals/32/105527_2.png) [@tastyminerals](https://discuss.elastic.co/u/tastyminerals)\
**Post date:** [August 25, 2022, 7:58am UTC](https://discuss.elastic.co/t/how-to-calculate-growth-for-a-sliding-time-window-with-a-yearly-offset/312880/1 "2022-08-25T07:58:58Z")

</div>

I would like to create a timelion visualizaiton which shows a % growth of received documents within a range of 1 week against the same week but a year ago. I am not sure if the below timelion expression does exactly that.

```auto
.es(index=received_docs, timefield=created_at, q='status:uploaded').mvavg(window=7d)
.divide(.es(index=received_docs, timefield=created_at, q='status:uploaded', offset=-1y).mvavg(window=7d))
.subtract(1)

```

Is there a visualization that can show just the growth numbers?  
Maybe using `.derivative()` is a better solution to show growth?

---

<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:** [September 22, 2022, 7:59am UTC](https://discuss.elastic.co/t/how-to-calculate-growth-for-a-sliding-time-window-with-a-yearly-offset/312880/2 "2022-09-22T07:59:34Z")

</div>

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