# How to graph only the stack total?

**URL:** https://discuss.elastic.co/t/how-to-graph-only-the-stack-total/197909
**Category:** Kibana
**Created:** [September 3, 2019, 4:32pm UTC](https://discuss.elastic.co/t/how-to-graph-only-the-stack-total/197909 "2019-09-03T16:32:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![dpr](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dpr](https://discuss.elastic.co/u/dpr)
#### Post date: [September 3, 2019, 4:32pm UTC](https://discuss.elastic.co/t/how-to-graph-only-the-stack-total/197909/1 "2019-09-03T16:32:44Z")

</div>

I've built a time-series line chart.

It has just one metric: the latest value of one of the term "item.value" (top hit, item.value, sort on @timestamp, max)

The primary bucket is a date histogram.

It has a second bucket ("split series") which separates the values by a term ("item name"). This produces about 10 lines on my chart, which I display stacked.

**The top line is the only one I care about: The total value of all my items over time.**

How can I graph just that total of the stack without showing the value of each item underneath it?

---

<div class="post-metadata">

### Author: ![Aaron\_Caldwell](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron_caldwell/32/45755_2.png) [@Aaron\_Caldwell](https://discuss.elastic.co/u/Aaron_Caldwell)
#### Post date: [September 4, 2019, 4:02pm UTC](https://discuss.elastic.co/t/how-to-graph-only-the-stack-total/197909/2 "2019-09-04T16:02:29Z")

</div>

Hello David,

It sounds like you want the [cumulative sum aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-cumulative-sum-aggregation.html) for a running total. Does that sound right?

Also, here's a [related issue](https://discuss.elastic.co/t/creating-a-cumalative-sum-visualization-split-on-terms/169576) in case it helps.

Regards,  
Aaron

---

<div class="post-metadata">

### Author: ![dpr](https://avatars.discourse-cdn.com/v4/letter/d/8797f3/32.png) [@dpr](https://discuss.elastic.co/u/dpr)
#### Post date: [September 4, 2019, 9:14pm UTC](https://discuss.elastic.co/t/how-to-graph-only-the-stack-total/197909/3 "2019-09-04T21:14:38Z")

</div>

Aaron:

Firstly, thank you so much for taking the time to look at my question and make a suggestion! I really appreciate it.

I don't think the cumulative sum aggregation is what I'm looking for. It appears to sum up all the values for a specific metric over time, giving me a running total of that metric.

**What I am looking for, instead, is the most recent sum of each split value in my "split series bucket"** (I am splitting on a name, and my metric is the last value for that name) .

For example: If my incoming data is

```
 { stock_portfolio: [
    { "name": "Apple", "value": 600 },
    { "name": "Amazon", "value": 300 },
    { "name": "Facebook","value": 400 },
    { "name": "Netflix", "value": 100 }
 ]}

```

I could graph the total portfolio value over time by creating a time-series graph with the latest value of `stock_portfolio.price`, with a series split on `stock_portfolio.name`, and stack the output. The top line represents what I want to see, but I don't want to see the underlying individual stock prices, only a line for the total portfolio value.

**In short, I am trying to graph the top line in a stacked chart, where the sub-elements are the result of a "split-series on term".** Is there a way to calculate the sum of the split-and-stack?

---

<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: [October 2, 2019, 9:14pm UTC](https://discuss.elastic.co/t/how-to-graph-only-the-stack-total/197909/4 "2019-10-02T21:14:50Z")

</div>

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