# Calculating one field from different documents

**URL:** <https://discuss.elastic.co/t/calculating-one-field-from-different-documents/119185>\
**Category:** Elasticsearch\
**Created:** [February 9, 2018, 8:45am UTC](https://discuss.elastic.co/t/calculating-one-field-from-different-documents/119185 "2018-02-09T08:45:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![phia](https://avatars.discourse-cdn.com/v4/letter/p/f19dbf/32.png) [@phia](https://discuss.elastic.co/u/phia)\
**Post date:** [February 9, 2018, 8:45am UTC](https://discuss.elastic.co/t/calculating-one-field-from-different-documents/119185/1 "2018-02-09T08:45:46Z")

</div>

Hello guys,

is it possible to calculate with one field of two different documents? 🤷🏻‍♀️

**Example:**  
I have two documents with the fields "jobID", "number", "jobType" and some others, which are not important.  
What I want to do is a subtraction of the numbers from documents with the same jobID and two different specific typeOfJobs. So as two with "jobId = 5" and " **number** (of jobType = One) **- number** (of jobType = Two)".

Thanks in advance. 🙂

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [February 9, 2018, 9:20am UTC](https://discuss.elastic.co/t/calculating-one-field-from-different-documents/119185/2 "2018-02-09T09:20:40Z")

</div>

See this question on deriving values from multiple docs based on a common ID: [How to search relationship between log lines](https://discuss.elastic.co/t/how-to-search-relationship-between-log-lines/119078)

---

<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 9, 2018, 9:20am UTC](https://discuss.elastic.co/t/calculating-one-field-from-different-documents/119185/3 "2018-03-09T09:20:49Z")

</div>

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