# Difference between two fields based on a field value filter

**URL:** <https://discuss.elastic.co/t/difference-between-two-fields-based-on-a-field-value-filter/204492>\
**Category:** Elasticsearch\
**Created:** [October 21, 2019, 2:05pm UTC](https://discuss.elastic.co/t/difference-between-two-fields-based-on-a-field-value-filter/204492 "2019-10-21T14:05:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Prashant\_Kumar3](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/prashant_kumar3/32/48977_2.png) [@Prashant\_Kumar3](https://discuss.elastic.co/u/Prashant_Kumar3)\
**Post date:** [October 21, 2019, 2:05pm UTC](https://discuss.elastic.co/t/difference-between-two-fields-based-on-a-field-value-filter/204492/1 "2019-10-21T14:05:46Z")

</div>

Hi,I need to find the time difference between two fields from two different hits or events or \_source .  
For example.  
Each hit contain a field @timestamp  
OUR APPLIED FILTER (Based on question\_id or \_id)  
which returns 20 hits.

So what I need is time difference between the 1st hit and 20th hit of the timestamp field.  
(Similarly like transaction in splunk).

---

<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:** [November 18, 2019, 2:05pm UTC](https://discuss.elastic.co/t/difference-between-two-fields-based-on-a-field-value-filter/204492/2 "2019-11-18T14:05:57Z")

</div>

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