# How to query in ES interval value diiference

**URL:** <https://discuss.elastic.co/t/how-to-query-in-es-interval-value-diiference/76093>\
**Category:** Elasticsearch\
**Created:** [February 22, 2017, 7:24pm UTC](https://discuss.elastic.co/t/how-to-query-in-es-interval-value-diiference/76093 "2017-02-22T19:24:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajay\_bh111](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@ajay\_bh111](https://discuss.elastic.co/u/ajay_bh111)\
**Post date:** [February 22, 2017, 7:24pm UTC](https://discuss.elastic.co/t/how-to-query-in-es-interval-value-diiference/76093/1 "2017-02-22T19:24:52Z")

</div>

Is there a way to query in Elasticsearch, when time series documents contain cumulative value, and I want to find out the incremental value of the field between current document and one that was created 10 seconds ago. For example say a field COUNT contains value 100 in the document with creation time stamp as 14:00:00 and the document created at 14:00:10 contains value 125. So increemental value is 25 (125 -100) , both documents are in same index and type.

---

<div class="post-metadata">

**Author:** ![mnozawa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mnozawa/32/15091_2.png) [@mnozawa](https://discuss.elastic.co/u/mnozawa)\
**Post date:** [February 23, 2017, 12:07am UTC](https://discuss.elastic.co/t/how-to-query-in-es-interval-value-diiference/76093/2 "2017-02-23T00:07:48Z")

</div>

Hi,

I think the Derivative Aggregation may help you.  
[https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-derivative-aggregation.html](https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-aggregations-pipeline-derivative-aggregation.html)

---

<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 23, 2017, 12:08am UTC](https://discuss.elastic.co/t/how-to-query-in-es-interval-value-diiference/76093/3 "2017-03-23T00:08:04Z")

</div>

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