# Help! How to aggs data by two or more fields, and get the max value of 'count' field?

**URL:** <https://discuss.elastic.co/t/help-how-to-aggs-data-by-two-or-more-fields-and-get-the-max-value-of-count-field/315345>\
**Category:** Kibana\
**Created:** [September 28, 2022, 9:41am UTC](https://discuss.elastic.co/t/help-how-to-aggs-data-by-two-or-more-fields-and-get-the-max-value-of-count-field/315345 "2022-09-28T09:41:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dosia96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dosia96/32/111379_2.png) [@Dosia96](https://discuss.elastic.co/u/Dosia96)\
**Post date:** [September 28, 2022, 9:41am UTC](https://discuss.elastic.co/t/help-how-to-aggs-data-by-two-or-more-fields-and-get-the-max-value-of-count-field/315345/1 "2022-09-28T09:41:25Z")

</div>

How to aggs data by two or more fields, and get the max value of 'count' field?

I have already config the kibana

- Y-Axis: Metrics sum('count'),
- X-Axis: Data Histogram @timestamp , interval : sec  
terms field(a) order by count desc,  
terms field(b) order by count desc,

but because of the number of the data is too large, kibana always change my time interval to 5min  
but I want 1s .  
and the result of the max count seems wrong because when I config the size of field a , b to 1, the max is a number, when I turn it to 2 or more, the max value is another number... is there some thing wrong?

thanks very much!!

---

<div class="post-metadata">

**Author:** ![cheiligers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cheiligers/32/73114_2.png) [@cheiligers](https://discuss.elastic.co/u/cheiligers)\
**Post date:** [September 28, 2022, 8:31pm UTC](https://discuss.elastic.co/t/help-how-to-aggs-data-by-two-or-more-fields-and-get-the-max-value-of-count-field/315345/2 "2022-09-28T20:31:27Z")

</div>

Welcome to the community @Dosia96 !  
Aggregations have change a bit over the last few kibana minors and there were big changes between 7.x and the 8.0 version.  
I don't know what version of Kibana you're using, or exactly how you're doing the aggregation (a visualization, a query or a search etc) so I'll give general suggestions.

You could try changing your aggregation to use split rows. In lens:

 ![lens_split_rows](https://us1.discourse-cdn.com/elastic/original/3X/8/4/84def50a60e43a9d86870daa2ca740ef25c642f7.png)  
You'll want to choose the metrics and columns you need.

For a aggregation based example (table) try:

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

If neither of those does what you want, you could try some of the other methods discussed here: [Aggregation-based | Kibana Guide [8.4] | Elastic](https://www.elastic.co/guide/en/kibana/current/add-aggregation-based-visualization-panels.html#add-aggregation-based-visualization-panels)

---

<div class="post-metadata">

**Author:** ![Dosia96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dosia96/32/111379_2.png) [@Dosia96](https://discuss.elastic.co/u/Dosia96)\
**Post date:** [September 30, 2022, 6:52am UTC](https://discuss.elastic.co/t/help-how-to-aggs-data-by-two-or-more-fields-and-get-the-max-value-of-count-field/315345/3 "2022-09-30T06:52:59Z")

</div>

thank !

---

<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 28, 2022, 6:53am UTC](https://discuss.elastic.co/t/help-how-to-aggs-data-by-two-or-more-fields-and-get-the-max-value-of-count-field/315345/4 "2022-10-28T06:53:42Z")

</div>

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