# Visual Builder - "count" field definition

**URL:** https://discuss.elastic.co/t/visual-builder-count-field-definition/101831
**Category:** Kibana
**Created:** [September 26, 2017, 10:44am UTC](https://discuss.elastic.co/t/visual-builder-count-field-definition/101831 "2017-09-26T10:44:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)
#### Post date: [September 26, 2017, 10:44am UTC](https://discuss.elastic.co/t/visual-builder-count-field-definition/101831/1 "2017-09-26T10:44:59Z")

</div>

Hi, I have created in Visual Builder chart. I am using "count" agg. "Count" should show "the last value in that case".

What is definition of last value in that case? Is it the value from last event? What if in the same time, I will receive two events? Will it sum it up?

Thanks for clarification.

---

<div class="post-metadata">

### Author: ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)
#### Post date: [September 26, 2017, 9:13pm UTC](https://discuss.elastic.co/t/visual-builder-count-field-definition/101831/2 "2017-09-26T21:13:57Z")

</div>

The count aggregation will tell you the number of documents in that bucket. For example if you receive 5 events count will be 5.

If you need something like the last value added to a bucket you'll want to use the top hits agg, sorted by timestamp for example.

---

<div class="post-metadata">

### Author: ![Akaren](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Akaren](https://discuss.elastic.co/u/Akaren)
#### Post date: [September 27, 2017, 7:34am UTC](https://discuss.elastic.co/t/visual-builder-count-field-definition/101831/3 "2017-09-27T07:34:27Z")

</div>

This is how it works in Kibana charts but not in Visual Builder.

For example here

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

If I switxh to metric, the count is zero, not 10. I have already asked about that here [Visual Builder - time range for count?](https://discuss.elastic.co/t/visual-builder-time-range-for-count/100858)

But my question now is about defenition of "Count" aggregation.

---

<div class="post-metadata">

### Author: ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)
#### Post date: [September 27, 2017, 6:07pm UTC](https://discuss.elastic.co/t/visual-builder-count-field-definition/101831/4 "2017-09-27T18:07:19Z")

</div>

Ah I understand now. The last value for the metric will be the right most point on the time series chart. It will be last bucket created, with the bucket time range is dependent on the interval.

If you want it to be 10 you can use a cumulative sum aggregation

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/6/46a7bd2c9f2c40ba7880f2e034d9bff9b242904f.png)

---

<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 25, 2017, 6:07pm UTC](https://discuss.elastic.co/t/visual-builder-count-field-definition/101831/5 "2017-10-25T18:07:20Z")

</div>

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