# How to show the aggregation result in kibana?

**URL:** https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236
**Category:** Kibana
**Created:** [March 21, 2019, 12:48am UTC](https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236 "2019-03-21T00:48:41Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sky\_Iprd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sky_iprd/32/38984_2.png) [@Sky\_Iprd](https://discuss.elastic.co/u/Sky_Iprd)
#### Post date: [March 21, 2019, 12:48am UTC](https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236/1 "2019-03-21T00:48:41Z")

</div>

Hi , i have follow script do aggregation of the production year revenue. However, I dunno how can I use the visualization to present the result. Please help or point me some direction please and thanks.

> POST elk\_all/sales\_daily  
> {  
> "code": 2,  
> "name": "RedTB",  
> "year": 2018,  
> "sales": 1000  
> }  
> POST elk\_all/sales\_daily  
> {  
> "code": 1,  
> "name": "BlueTB",  
> "year": 2018,  
> "sales": 1000  
> }  
> POST elk\_all/sales\_daily  
> {  
> "code": 2,  
> "name": "RedTB",  
> "year": 2017,  
> "sales": 600  
> }  
> POST elk\_all/sales\_daily  
> {  
> "code": 1,  
> "name": "BlueTB",  
> "year": 2017,  
> "sales": 920  
> }  
> POST elk\_all/sales\_daily  
> {  
> "code": 2,  
> "name": "RedTB",  
> "year": 2016,  
> "sales": 800  
> }  
> POST elk\_all/sales\_daily  
> {  
> "code": 1,  
> "name": "BlueTB",  
> "year": 2016,  
> "sales": 900  
> }  
> GET elk\_all/\_search  
> {  
> "size": 0,  
> "query": {  
> "bool": {  
> "must": {  
> "range": {  
> "year": {  
> "gte": "2016",  
> "lte": "2018"  
> }  
> }  
> }  
> }  
> },  
> "aggs": {  
> "group\_by\_code": {  
> "terms": {  
> "field": "code"  
> },  
> "aggs": {  
> "first\_sale": {  
> "filter": {  
> "term": {  
> "year": "2016"  
> }  
> },  
> "aggs": {  
> "sales\_value": {  
> "max": {  
> "field": "sales"  
> }  
> }  
> }  
> },  
> "mid\_sale": {  
> "filter": {  
> "term": {  
> "year": "2017"  
> }  
> },  
> "aggs": {  
> "sales\_value": {  
> "max": {  
> "field": "sales"  
> }  
> }  
> }  
> },  
> "last\_sale": {  
> "filter": {  
> "term": {  
> "year": "2018"  
> }  
> },  
> "aggs": {  
> "sales\_value": {  
> "max": {  
> "field": "sales"  
> }  
> }  
> }  
> },  
> "filter\_positive": {  
> "bucket\_selector": {  
> "buckets\_path": {  
> "first": "first\_sale\>sales\_value",  
> "mid": "mid\_sale\>sales\_value",  
> "last": "last\_sale\>sales\_value"  
> },  
> "script": "params.last \> params.mid && params.mid \< params.first"  
> }  
> }  
> }  
> }  
> }  
> }

---

<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: [March 22, 2019, 11:52am UTC](https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236/2 "2019-03-22T11:52:50Z")

</div>

For start, create a line chart with a SUM metric (anything actually if you're showing them by year), a terms aggregation on the `year` field or a histogram one, depending on what you want to do with it.  
And if you want show them for RedTB and BlueTB separately, just click on Split Chart and then select either a terms aggregation on the name or a filter aggregation with the name as terms.

---

<div class="post-metadata">

### Author: ![Sky\_Iprd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sky_iprd/32/38984_2.png) [@Sky\_Iprd](https://discuss.elastic.co/u/Sky_Iprd)
#### Post date: [March 24, 2019, 8:42am UTC](https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236/3 "2019-03-24T08:42:38Z")

</div>

Thanks for guiding me. The line chart contains both product now. However, I try to put my aggregation script in the filter DSL it's doesn't help me to filter out the product ( code:1 ) I don't want to show in graph because code 1 is not match in my scenario. Am I missing something ?  
The script work well in the dev tools ...

---

<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: [March 25, 2019, 12:31pm UTC](https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236/4 "2019-03-25T12:31:34Z")

</div>

Can you show me a screenshot of your chart and the options that you set? It would be easier to troubleshoot that way.

---

<div class="post-metadata">

### Author: ![Sky\_Iprd](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sky_iprd/32/38984_2.png) [@Sky\_Iprd](https://discuss.elastic.co/u/Sky_Iprd)
#### Post date: [March 26, 2019, 12:41pm UTC](https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236/5 "2019-03-26T12:41:34Z")

</div>

Yes, here it is. Thanks..

1st jpg is the line chart output

 ![41](https://us1.discourse-cdn.com/elastic/original/3X/8/4/84b17b8ae4dc24bc8a23f0139d0226e75951d0b9.png)

2nd Y-Axis Metric

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

3rd X-Axis Metric

 ![10](https://us1.discourse-cdn.com/elastic/original/3X/3/8/38d45e510c6312c6678fd05b978cfd904b95a036.png)

 ![18](https://us1.discourse-cdn.com/elastic/original/3X/b/6/b6a10b7b1b434ab7b82fab867782cc3ee728da7d.png)

4th The result come from the aggregation script query I post in previous thread

 ![05](https://us1.discourse-cdn.com/elastic/original/3X/3/6/36a3b79b77a0b5dba66a9499d21eb10b40c5bb8e.png)

Thanks 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: [April 23, 2019, 12:41pm UTC](https://discuss.elastic.co/t/how-to-show-the-aggregation-result-in-kibana/173236/6 "2019-04-23T12:41:37Z")

</div>

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