# Visualize aggs min as sub bucket

**URL:** <https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431>\
**Category:** Kibana\
**Created:** [August 23, 2019, 3:32am UTC](https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431 "2019-08-23T03:32:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mmk1995](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmk1995](https://discuss.elastic.co/u/mmk1995)\
**Post date:** [August 23, 2019, 3:32am UTC](https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431/1 "2019-08-23T03:32:14Z")

</div>

Hello all,  
I have the below elasticsearch query

> GET /monthly-data/\_search  
> {  
> "size": 0,  
> "aggs": {  
> "accname": {  
> "terms": {  
> "field": "User.keyword"  
> },  
> "aggs": {  
> "year ": {  
> "terms": {  
> "field": "Year.keyword"  
> },  
> "aggs" : {  
> "min\_date" : { "min" : { "field" : "@timestamp" } }  
> }  
> }  
> }  
> }  
> }  
> }

How should I put the aggregation result to visualization and the Y-Axis to be cumulative sum?  
I wish I could have the cumulative sum overtime for min(@timestamp) group by "user" and "year"

Thank you!

---

<div class="post-metadata">

**Author:** ![mmk1995](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmk1995](https://discuss.elastic.co/u/mmk1995)\
**Post date:** [August 23, 2019, 3:36am UTC](https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431/2 "2019-08-23T03:36:36Z")

</div>

For more info, this is a further question of the following thread  
[https://discuss.elastic.co/t/how-elasticsearch-query-should-be-written-for-the-following-sql-statement/196288/10](https://discuss.elastic.co/t/how-elasticsearch-query-should-be-written-for-the-following-sql-statement/196288/10)

---

<div class="post-metadata">

**Author:** ![mmk1995](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmk1995](https://discuss.elastic.co/u/mmk1995)\
**Post date:** [August 26, 2019, 4:30am UTC](https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431/3 "2019-08-26T04:30:23Z")

</div>

any help pls?

---

<div class="post-metadata">

**Author:** ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)\
**Post date:** [August 28, 2019, 2:02am UTC](https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431/4 "2019-08-28T02:02:40Z")

</div>

There are a number of details that need to be correct in order to do this - can you share a screenshot of your results so far? I'm uncertain where in the process you're getting stuck.

---

<div class="post-metadata">

**Author:** ![mmk1995](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mmk1995](https://discuss.elastic.co/u/mmk1995)\
**Post date:** [August 28, 2019, 9:24am UTC](https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431/5 "2019-08-28T09:24:21Z")

</div>

hello Matthew Kime,  
I am Matthew too, but Matthew Mak 😃  
I think I am quite clear on my question

> I wish I could have the cumulative sum overtime for min(@timestamp) group by "user" and "year"

How would you do this in Kibana Visualization (eg Line Chart)?  
For example, there is data like:  
timestamp, user, study\_year  
2018-09-01, abc, year\_1  
2018-09-10, abc, year\_1  
2018-09-20, abc, year\_1  
2018-09-25, xyz, year\_2  
2018-09-29, xyz, year\_2

if I doing -----\> min(@timestamp) group by "user" and "year"  
the data set will be:  
timestamp, user, study\_year  
2018-09-01, abc, year\_1  
2018-09-25, xyz, year\_2

and then I want to plot a Line Chart  
Y axis will be the cumulative sum of the student count, X axis will be the time series  
How could Kibana do this?

Thank you in advance

---

<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 25, 2019, 9:24am UTC](https://discuss.elastic.co/t/visualize-aggs-min-as-sub-bucket/196431/6 "2019-09-25T09:24:24Z")

</div>

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