# Create a table counting the number of buckets having same count (count pipeline ?)

**URL:** <https://discuss.elastic.co/t/create-a-table-counting-the-number-of-buckets-having-same-count-count-pipeline/252914>\
**Category:** Kibana\
**Created:** [October 21, 2020, 11:44pm UTC](https://discuss.elastic.co/t/create-a-table-counting-the-number-of-buckets-having-same-count-count-pipeline/252914 "2020-10-21T23:44:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tenchi](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@tenchi](https://discuss.elastic.co/u/tenchi)\
**Post date:** [October 21, 2020, 11:44pm UTC](https://discuss.elastic.co/t/create-a-table-counting-the-number-of-buckets-having-same-count-count-pipeline/252914/1 "2020-10-21T23:44:42Z")

</div>

Hello,  
I have an index with a line for each customer order.  
I am trying to get a visualization table listing the number of customers ordering several times, with one line per number of recurrent orders.

| Number of orders | Number of customers |
| --- | --- |
| 1 | 10 |
| 2 | 5 |
| 4 | 3 |

Didn't find a solution with aggregation pipelines... What did I miss ?  
Thank you for your help !

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [October 22, 2020, 6:32pm UTC](https://discuss.elastic.co/t/create-a-table-counting-the-number-of-buckets-having-same-count-count-pipeline/252914/2 "2020-10-22T18:32:53Z")

</div>

Hi, I think this is possible by changing the structure of your data to be customer-oriented instead of order-oriented. This is part of the functionality we offer as [data transforms](https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html).

Basically you can create a transformation that aggregates this way:

- Group by customer ID
- Count the orders per customer

Then you can easily create the visualization you want on top of the pre-aggregated data

---

<div class="post-metadata">

**Author:** ![tenchi](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@tenchi](https://discuss.elastic.co/u/tenchi)\
**Post date:** [October 23, 2020, 12:32pm UTC](https://discuss.elastic.co/t/create-a-table-counting-the-number-of-buckets-having-same-count-count-pipeline/252914/3 "2020-10-23T12:32:35Z")

</div>

Thank you fio your quick answer Wylie !  
So it seems there is no simple Kibana based solution.

Sort of equivalent to :

`select count(*) from (select count(*) as qty from orderIndex group by customer_name) group by qty`

---

<div class="post-metadata">

**Author:** ![wylie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wylie/32/81794_2.png) [@wylie](https://discuss.elastic.co/u/wylie)\
**Post date:** [October 26, 2020, 2:46pm UTC](https://discuss.elastic.co/t/create-a-table-counting-the-number-of-buckets-having-same-count-count-pipeline/252914/4 "2020-10-26T14:46:11Z")

</div>

Exactly. Kibana is (with a few exceptions) limited by what you can express using a single Elasticsearch query, which is why I recommended changing the structure of the data.

---

<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:** [November 23, 2020, 2:46pm UTC](https://discuss.elastic.co/t/create-a-table-counting-the-number-of-buckets-having-same-count-count-pipeline/252914/5 "2020-11-23T14:46:11Z")

</div>

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