# Elasticsearch how to subtract field number value with specific number

**URL:** <https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090>\
**Category:** Kibana\
**Created:** [November 3, 2022, 10:05am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090 "2022-11-03T10:05:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![pratikshatiwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pratikshatiwari/32/116646_2.png) [@pratikshatiwari](https://discuss.elastic.co/u/pratikshatiwari)\
**Post date:** [November 3, 2022, 10:05am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090/1 "2022-11-03T10:05:28Z")

</div>

Hello

I am looking for solution to prepare dashboard in which i need to prepare a visualization with difference value

e.g. site performance field mentioned as 500ms but as per threshold it should be 200ms

Field name "A" contains the performance number which 500ms

Requirement I want to obtain the difference between the performance number which is field "A" with performance threashold 200ms

Kindly assist if it is possible and how we can use it for dashboard

Regards  
Pratiksha

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [November 3, 2022, 10:37am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090/2 "2022-11-03T10:37:08Z")

</div>

Hi @pratikshatiwari

I think you have two options in Lens for your case:

- either use a "Reference line" here rather than a difference to show a comparison baseline - see the "Static value" in the special layer at the bottom

 ![Screenshot 2022-11-03 at 11.32.52](https://us1.discourse-cdn.com/elastic/original/3X/2/c/2c2781a4743eeb191489a27e9ff39f8b3c4a21ab.jpeg)

- Use a formula to compute the delta ( value - static value ):

![Screenshot 2022-11-03 at 11.36.52](https://us1.discourse-cdn.com/elastic/original/3X/9/a/9a0ef633e390468bac746b5c6b7d55dec507c974.png)

---

<div class="post-metadata">

**Author:** ![pratikshatiwari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pratikshatiwari/32/116646_2.png) [@pratikshatiwari](https://discuss.elastic.co/u/pratikshatiwari)\
**Post date:** [November 3, 2022, 11:07am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090/3 "2022-11-03T11:07:48Z")

</div>

hi @Marco_Liberati

Thank you for the responce, but the obtained visualization not working out for me

I have created attached visualization in tsvb, i need to add one more number column next to second column with substracted no.

e.g. first url hit time is 29.48s and and next to that i want to add one more column with substracted no. e.g "28.88s"

As 28.88 second obtained after substracting 29.48 with 200 ms

![image](https://us1.discourse-cdn.com/elastic/original/3X/d/b/db987b622125a1c45531d2a283d27b0b16168651.png)

All i want to achieve here is to show the url which created high hit along with theii hit number & recomended no. to come down be healthy site by substracting with average threshold

Same loginc i want to apply all

PFA example visualization view from excel

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/e/6e30eac0d0d7553581d7a5aa09aa3ca0a45488e3.png)

Regards  
Pratiksha

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [November 3, 2022, 11:44am UTC](https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090/4 "2022-11-03T11:44:36Z")

</div>

I see your use case, I think the second option with formula should work ok in your case then.  
I've quickly put together a similar chart using the flight sample date here:

 ![Screenshot 2022-11-03 at 12.41.31](https://us1.discourse-cdn.com/elastic/original/3X/6/4/646d02a5f7af00196549dee9c6dd970c434601f5.png)

For each airport city I'm taking the last flight time (in minutes) and remove 5 minutes from each.  
It is not clear which aggregation you've used in the TSVB, but it can be applied in Lens formula as well (change `last_value` to `max` or any other metric agg you've used).

---

<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 30, 2022, 8:30pm UTC](https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090/5 "2022-11-30T20:30:31Z")

</div>



---

<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:** [December 28, 2022, 8:30pm UTC](https://discuss.elastic.co/t/elasticsearch-how-to-subtract-field-number-value-with-specific-number/318090/6 "2022-12-28T20:30:48Z")

</div>

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