# TSVB: aggregate across ALL documents in index, not just those in a selected time range

**URL:** https://discuss.elastic.co/t/tsvb-aggregate-across-all-documents-in-index-not-just-those-in-a-selected-time-range/272852
**Category:** Kibana
**Created:** [May 12, 2021, 9:11pm UTC](https://discuss.elastic.co/t/tsvb-aggregate-across-all-documents-in-index-not-just-those-in-a-selected-time-range/272852 "2021-05-12T21:11:24Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ivh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivh/32/87876_2.png) [@ivh](https://discuss.elastic.co/u/ivh)
#### Post date: [May 12, 2021, 9:11pm UTC](https://discuss.elastic.co/t/tsvb-aggregate-across-all-documents-in-index-not-just-those-in-a-selected-time-range/272852/1 "2021-05-12T21:11:24Z")

</div>

Hello! I have a working aggregation (cumulative sum) that behaves as expected when I've used the time picker to select a date range large enough (i.e., goes far enough back in time) to calculate the agg cumulative sum across ALL documents in the index)...

 ![Screen Shot 2021-05-12 at 2.13.21 PM](https://us1.discourse-cdn.com/elastic/original/3X/a/c/ac8031931f0dfa6d3300dc2956a578849dcb8f67.png)

...but when I reduce the date range via time picker to, say, the last week... what I see is this...

 ![Screen Shot 2021-05-12 at 2.13.58 PM](https://us1.discourse-cdn.com/elastic/original/3X/a/7/a74e2b9cc7ad3ab3b220401fe1be183552343306.png)

...where clearly documents in the index with timestamps older than 1 week are omitted ... whereas I expected to see this (at the far-right side of the graph)...

 ![Screen Shot 2021-05-12 at 2.14.39 PM](https://us1.discourse-cdn.com/elastic/original/3X/1/c/1cd66e1e6ab2e99f492b1aef8de60e4dcad105ed.png)

In other words: how do I instruct TSVB to search **ALL** documents in the index for the calculated/aggregated field ... instead of just those documents from the time range specified by the selected time-picker setting?

I've tried augmenting my filter query for the aggregation...

`coin_bot_name_short:ETH AND coin_bot_datetime>"2021-04-01"`  
( or )  
`coin_bot_name_short:ETH AND coin_bot_datetime:*`

...but no luck.

Any help appreciated.

Kibana 7.12

---

<div class="post-metadata">

### Author: ![Marius\_Dragomir](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marius_dragomir/32/42087_2.png) [@Marius\_Dragomir](https://discuss.elastic.co/u/Marius_Dragomir)
#### Post date: [May 13, 2021, 9:04am UTC](https://discuss.elastic.co/t/tsvb-aggregate-across-all-documents-in-index-not-just-those-in-a-selected-time-range/272852/2 "2021-05-13T09:04:50Z")

</div>

This isn't possible, the request is done only for the interval selected.  
There is sort of an workaround if you use the Math aggregation to add the sum up to the point of start to the values shown, but you'd have to update that continuously if you have a dynamic interval (like 7 days ago -\> now)

---

<div class="post-metadata">

### Author: ![ivh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivh/32/87876_2.png) [@ivh](https://discuss.elastic.co/u/ivh)
#### Post date: [May 13, 2021, 3:59pm UTC](https://discuss.elastic.co/t/tsvb-aggregate-across-all-documents-in-index-not-just-those-in-a-selected-time-range/272852/3 "2021-05-13T15:59:13Z")

</div>

OK thx Marius. Other option is simply write the cumulative sum to the index each day which is likely what I’ll do.

---

<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: [June 10, 2021, 4:00pm UTC](https://discuss.elastic.co/t/tsvb-aggregate-across-all-documents-in-index-not-just-those-in-a-selected-time-range/272852/4 "2021-06-10T16:00:07Z")

</div>

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