# How to change y-axis to show field value which is already an aggregate

**URL:** https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504
**Category:** Kibana
**Created:** [October 27, 2017, 3:46am UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504 "2017-10-27T03:46:48Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![lemongrab](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@lemongrab](https://discuss.elastic.co/u/lemongrab)
#### Post date: [October 27, 2017, 3:46am UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/1 "2017-10-27T03:46:48Z")

</div>

I have an array of data points objects that follow this format:

{pizzasBought: 50, time:13:10}

I want the x-axis to be set to time and pizzasBought which is already an aggregate to the y-axis and was wondering how to do this in Kibana.

One way to do this, I suppose, is to write a loop that generates 50 json objects, each representing a pizza bought with property time at 13:10, like so ({time: 13:10}), but that sounds like an exercise in futility and a waste of time.

Anything that doesn't involve this method would be much appreciated.

Thanks.

---

<div class="post-metadata">

### Author: ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)
#### Post date: [October 27, 2017, 8:18pm UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/2 "2017-10-27T20:18:34Z")

</div>

So you're indexing data into Elasticsearch that way?

The fact the number bought is an aggregate already doesn't matter much. You're recording the number bought at a given time, but Elasticsearch (and Kibana by extension) will allow you to see the number in a given time bucket. For example, the total number bought every hour.

This is a pretty easy to accomplish. In Kibana, simply do a date-histogram agg on the X-axis and set the metric to some math operation that's not count (Max, Sum, Average, Mean, etc. are all fine). That'll bucket up the data in blocks of time and show you purchase counts over time.

---

<div class="post-metadata">

### Author: ![lemongrab](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@lemongrab](https://discuss.elastic.co/u/lemongrab)
#### Post date: [October 28, 2017, 12:28am UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/3 "2017-10-28T00:28:12Z")

</div>

yes. More precisely, I'm indexing my data as follows

index: pizzas  
{pizzasBought: 50, createdAt:13:10:10, dayOfWeek: 1}

index: calls  
{callsReceived: 100, hour: 23, dayOfWeek: 1}

This is over the course of 2 days so far in five second intervals. using a date histogram gives me an error "the interval creates too many buckets" when I group by hour. I'd like to get an average of the number of pizzas ordered by hour (1pm, 2pm, etc) but wasn't sure how to go about doing this. I am able to get the index calls to show up on another graph but would also like that to display on the same line chart as the one for the pizzas ordered index. Thanks.

---

<div class="post-metadata">

### Author: ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)
#### Post date: [October 30, 2017, 3:56pm UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/4 "2017-10-30T15:56:59Z")

</div>

> using a date histogram gives me an error "the interval creates too many buckets" when I group by hour

That sounds very odd. Hourly buckets shouldn't be a problem... unless maybe you're trying to view a large timeframe. If you are, you may need to pick a larger bucket instead of hourly.

Can you share a screenshot of the side bar in Visualize, so I can see how you're building the visualization?

---

<div class="post-metadata">

### Author: ![lemongrab](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@lemongrab](https://discuss.elastic.co/u/lemongrab)
#### Post date: [November 6, 2017, 7:09pm UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/5 "2017-11-06T19:09:54Z")

</div>

I changed things a bit and I'm not exactly which of the steps that I took resolved the issue, but the time interval issue has been resolved. I've changed the indexing format as follows:

index: pizza  
type: purchase  
{pizzasBought: 50, createdAt:13:10:10, dayOfWeek: 1}

index: pizza  
type: calls  
{callsReceived: 100, dayOfWeek: 1, createdAt: 13:10:10}

I'm now wondering how I'd be able to show the following on the same visualization:  
-average number of purchases in hourly intervals  
-sum of calls placed in hourly intervals

---

<div class="post-metadata">

### Author: ![Joe\_Fleming](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joe_fleming/32/3561_2.png) [@Joe\_Fleming](https://discuss.elastic.co/u/Joe_Fleming)
#### Post date: [November 8, 2017, 4:12pm UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/6 "2017-11-08T16:12:52Z")

</div>

> I'm now wondering how I'd be able to show the following _on the same visualization_

You're not going to be able to do this on the same visualization, at least not with normal visualizations in Kibana, like the basic area, line, bar, pie charts and all those. Since you have different filter requirements for those records, they are different series, and those visualizations only support a single series.

You _can_ do this with the Visual Builder vis in Kibana though, since it supports multiple series on the same chart. In that case, you add two series, one filtered on the `type: purchase` and showing the sum of the `pizzasBought` field, and the other filtered on `type: calls` and showing the sum of the `callsReceived`.

---

<div class="post-metadata">

### Author: ![lemongrab](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@lemongrab](https://discuss.elastic.co/u/lemongrab)
#### Post date: [December 2, 2017, 1:10am UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/7 "2017-12-02T01:10:59Z")

</div>

thanks for the response. I'll look into that solution.

---

<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: [December 30, 2017, 1:11am UTC](https://discuss.elastic.co/t/how-to-change-y-axis-to-show-field-value-which-is-already-an-aggregate/105504/8 "2017-12-30T01:11:10Z")

</div>

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