# Create field based on calculated data

**URL:** <https://discuss.elastic.co/t/create-field-based-on-calculated-data/242138>\
**Category:** Elasticsearch\
**Created:** [July 22, 2020, 6:32am UTC](https://discuss.elastic.co/t/create-field-based-on-calculated-data/242138 "2020-07-22T06:32:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Magnuss](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnuss/32/66169_2.png) [@Magnuss](https://discuss.elastic.co/u/Magnuss)\
**Post date:** [July 22, 2020, 6:32am UTC](https://discuss.elastic.co/t/create-field-based-on-calculated-data/242138/1 "2020-07-22T06:32:40Z")

</div>

Dear reader,

I would like to do the following:

I get data ingested everyday with the following fields.(example)  
Day 1

- stock: 200
- price: 10  
Day 2
- stock 200
- price: 10  
Day 1
- stock: 200
- price: 10  
Day 3
- stock 190
- price: 10

Etc etc

Now I would like to know the difference over a week of the stock. For example end of the week is 100 stock.

I would like a field weekly-sales: 100  
Now I would like the calculate the revenue in a field. Weekly-sales: 100 times price: 10 = 1000

New field Revenue: 1000

How does this work in elastic?

---

<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:** [August 19, 2020, 6:32am UTC](https://discuss.elastic.co/t/create-field-based-on-calculated-data/242138/2 "2020-08-19T06:32:48Z")

</div>

Closed on August 19, 2020, 6:32am UTC

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