# Subtraction of Sum Aggregate Values in one Index from Sum Aggregate Values in Another Index

**URL:** <https://discuss.elastic.co/t/subtraction-of-sum-aggregate-values-in-one-index-from-sum-aggregate-values-in-another-index/338442>\
**Category:** Kibana\
**Created:** [July 14, 2023, 9:04pm UTC](https://discuss.elastic.co/t/subtraction-of-sum-aggregate-values-in-one-index-from-sum-aggregate-values-in-another-index/338442 "2023-07-14T21:04:17Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![nickbarry](https://avatars.discourse-cdn.com/v4/letter/n/8c91f0/32.png) [@nickbarry](https://discuss.elastic.co/u/nickbarry)\
**Post date:** [July 17, 2023, 3:58pm UTC](https://discuss.elastic.co/t/subtraction-of-sum-aggregate-values-in-one-index-from-sum-aggregate-values-in-another-index/338442/4 "2023-07-17T15:58:26Z")

</div>

And I'll answer my own question with my own response:

This required the creation of a pipeline aggregation found here: [Pipeline aggregations | Elasticsearch Guide [8.8] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline.html), as well as a bucket script consisting of a simple subtraction operation.

Then using this as a guide: [How to do Pipeline Aggregation in Time Series Visual Builder](https://discuss.elastic.co/t/how-to-do-pipeline-aggregation-in-time-series-visual-builder/142376), I added to my existing TVSB and obtained the output I was looking for.

---

_[View the full topic](https://discuss.elastic.co/t/subtraction-of-sum-aggregate-values-in-one-index-from-sum-aggregate-values-in-another-index/338442)._
