# Unique Count by Bucket

**URL:** https://discuss.elastic.co/t/unique-count-by-bucket/263978
**Category:** Kibana
**Created:** [February 11, 2021, 9:30am UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978 "2021-02-11T09:30:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Razvan\_Todea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/razvan_todea/32/83769_2.png) [@Razvan\_Todea](https://discuss.elastic.co/u/Razvan_Todea)
#### Post date: [February 11, 2021, 9:30am UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978/1 "2021-02-11T09:30:49Z")

</div>

How could we visualize an unique count grouped by bucket?  
We understand that the counting will only check the uniqueness inside the bucket, but is it another way to achieve this?

Example: We want to visualize all the unique products a merchant has.

 ![Screen Shot 2021-02-11 at 11.26.40 AM](https://us1.discourse-cdn.com/elastic/original/3X/b/0/b0acf7af682b3d700076c2a83f2c595e5f975145.png)

---

<div class="post-metadata">

### Author: ![dosant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dosant/32/64489_2.png) [@dosant](https://discuss.elastic.co/u/dosant)
#### Post date: [February 11, 2021, 1:52pm UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978/2 "2021-02-11T13:52:40Z")

</div>

Hi @Razvan_Todea, If I understood you correctly, then I think I've achieved what you've asked using TSVB:

Here I visualized uniq count of destinations per each carrier (using sample data set):

 ![Screenshot 2021-02-11 at 14.49.08](https://us1.discourse-cdn.com/elastic/original/3X/4/e/4e551bdad03c575d29cbfb4f5f07509e3cb8d350.jpeg)

---

<div class="post-metadata">

### Author: ![Razvan\_Todea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/razvan_todea/32/83769_2.png) [@Razvan\_Todea](https://discuss.elastic.co/u/Razvan_Todea)
#### Post date: [February 11, 2021, 2:52pm UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978/3 "2021-02-11T14:52:12Z")

</div>

Hi @dosant , thank you for the reply.  
I've checked your example, but it seems that is not working as expected. As you can see in the pictures. We have a total of 5 products -\> 3 products on merchant AWIN and 2 products on merchant Rakuten. But the ean: 1 appears in Rakuten and AWIN also (so is not unique). Instead of displaying that AWIN has 2 unique products, it should say that it only has 1 (the product with ean 3) and for Rakuten also 1 (the product with ean 2). The reasoning is that we want to know how many new products each merchant could get us.

 ![Screen Shot 2021-02-11 at 4.46.12 PM](https://us1.discourse-cdn.com/elastic/original/3X/c/b/cb2bc8ab39553ee1cc0a075586e220e0293d59be.png) ![Screen Shot 2021-02-11 at 4.46.44 PM](https://us1.discourse-cdn.com/elastic/original/3X/7/b/7b3ad4b7f2536c771dd946060ee88bee929bbd5f.png)

---

<div class="post-metadata">

### Author: ![dosant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dosant/32/64489_2.png) [@dosant](https://discuss.elastic.co/u/dosant)
#### Post date: [February 11, 2021, 3:29pm UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978/4 "2021-02-11T15:29:13Z")

</div>

What results you expect in case you have 3 merchants and 2 of them have a product and another doesn't?

---

<div class="post-metadata">

### Author: ![Razvan\_Todea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/razvan_todea/32/83769_2.png) [@Razvan\_Todea](https://discuss.elastic.co/u/Razvan_Todea)
#### Post date: [February 11, 2021, 3:43pm UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978/5 "2021-02-11T15:43:59Z")

</div>

In that case the product is not unique, so it should not be take into consideration for the count.

Merchant 1: product\_ean: 1  
Merchant 2: product\_ean: 1  
Merchant 3: product\_ean: 2

The result should be:  
Merchant 1: 0 unique products  
Merchant 2: 0 unique products  
Merchant 3: 1 unique products

---

<div class="post-metadata">

### Author: ![dosant](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dosant/32/64489_2.png) [@dosant](https://discuss.elastic.co/u/dosant)
#### Post date: [February 11, 2021, 4:13pm UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978/6 "2021-02-11T16:13:54Z")

</div>

Unfortunately, I didn't find a way how to achieve this in Kibana ☹ Hope I didn't miss something obvious.

In case you'd find a way how to build such a complex aggregation with [elasticsearch aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html) then you could try building custom [Vega](https://www.elastic.co/guide/en/kibana/7.11/vega.html) visualization for your custom aggregation.

---

<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: [March 11, 2021, 4:14pm UTC](https://discuss.elastic.co/t/unique-count-by-bucket/263978/7 "2021-03-11T16:14:16Z")

</div>

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