# Options to Create/Add a New Field

**URL:** <https://discuss.elastic.co/t/options-to-create-add-a-new-field/312507>\
**Category:** Kibana\
**Created:** [August 19, 2022, 9:32pm UTC](https://discuss.elastic.co/t/options-to-create-add-a-new-field/312507 "2022-08-19T21:32:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yolanda.darricarrere](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yolanda.darricarrere/32/109896_2.png) [@Yolanda.darricarrere](https://discuss.elastic.co/u/Yolanda.darricarrere)\
**Post date:** [August 19, 2022, 9:32pm UTC](https://discuss.elastic.co/t/options-to-create-add-a-new-field/312507/1 "2022-08-19T21:32:05Z")

</div>

Using the ecommerce data, I want to create a new field that is the total of products.taxful\_price minus products.discount\_amount (make it a double), then add the new field to a line graph using data from the past 7-days. I believe there should be 3-4 different ways to complete this task. Please share your approach. Cheers!

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [August 21, 2022, 1:53am UTC](https://discuss.elastic.co/t/options-to-create-add-a-new-field/312507/2 "2022-08-21T01:53:14Z")

</div>

Hi @Yolanda.darricarrere Welcome to the community!

I am curious what your experience level is with The Elastic Stack. I ask because The formula / question you stated above is great! seems straight forward! etc... _but_ with one exception....

The data fields you are referring to like `products.taxful_price` are contained within Array Fields. In Elasticsearch arrays are challenging to work with from my experience, especially if you happen to be just getting started with elasticsearch. Perhaps that is the point!

You can see here they are in arrays ... that is what that means

 ![Screen Shot 2022-08-20 at 6.06.17 PM](https://us1.discourse-cdn.com/elastic/original/3X/9/3/93b1a9c3e8f8756876ab151e21d7200670940b11.png)

So I am not quite sure if

**A)** you really want to deep dive into working with arrays in elasticsearch which is fine but non-trivial.

or

**B)** you just happen to pick the eCommerce sample data (which is what it is there for) and that data which seem cool / accessible but actually has some fairly complex data. (There are some other fields or sample data that you could work with that would be much easier to get started with)

if **A)** I would expect that you already have some familiarity with elasticsearch and the concepts of `_source` vs `fields`, mappings, and perhaps painless scripting... etc., and I only see one solution with is a fully scripting / writing some non-trivial code which again is fine... just unclear if that is what you are looking for (perhaps I am missing something and someone else knows another way)  
Basically it will involve be writing a small inline program looping through the array and doing the calculations you are looking for and producing the results... adding to the mapping / debugging it etc..

or

**B)** Perhaps start with some of the non-array fields to do a Runtime Field and / or Lens with formulas.

Which is what I _think_ your topic is about ... Doing Formulas in Lens or Adding a simple Runtime Field ... which again is non-trivial with array fields...

Like calculate the average price per product working with these fields or sums or percent of total etc...

 ![Screen Shot 2022-08-20 at 6.39.01 PM](https://us1.discourse-cdn.com/elastic/original/3X/3/2/328b8d84af02ff4943113a6196e085274d711304.png)

Let us know what your are after and perhaps someone can help.

Some great docs : This actually walks through a lot with the web logs data.

> **[Create visualizations with Lens | Kibana Guide \[8.3\] | Elastic](https://www.elastic.co/guide/en/kibana/current/lens.html)**
>
> Consider the production components that are used to generate reports.

Cool Blogs:

> **[10 common Kibana visualization questions answered with formulas and time travel](https://www.elastic.co/blog/kibana-10-common-questions-formulas-time-series-maps)**
>
> Kibana advanced analytics features enable you to tackle time series and geospatial data questions. Learn how to use formulas for calculations like ratios, week over week, deviations, and others — plus Elastic Maps tips for time / space questions.

There is a lot good free training an blogs as well.

> **[Free on-demand Elasticsearch and Kibana Training](https://www.elastic.co/training/free#how-to)**
>
> Elastic offers free introductory training for the Elastic (ELK) Stack - Elasticsearch, Kibana, Beats and Logstash. Learn the fundamentals of observability (logging, metrics, APM), security, SIEM, machine learning, & more with on-demand training

PS. Saw your other post, apologies I do not do tutoring, but there are a lot of good folks on this community perhaps one will reach out.

---

<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 18, 2022, 1:53am UTC](https://discuss.elastic.co/t/options-to-create-add-a-new-field/312507/3 "2022-09-18T01:53:30Z")

</div>

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