# Count values of one field based on uniqueness with another field

**URL:** <https://discuss.elastic.co/t/count-values-of-one-field-based-on-uniqueness-with-another-field/64025>\
**Category:** Kibana\
**Created:** [October 26, 2016, 3:40pm UTC](https://discuss.elastic.co/t/count-values-of-one-field-based-on-uniqueness-with-another-field/64025 "2016-10-26T15:40:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![piquadrat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/piquadrat/32/11226_2.png) [@piquadrat](https://discuss.elastic.co/u/piquadrat)\
**Post date:** [October 26, 2016, 3:40pm UTC](https://discuss.elastic.co/t/count-values-of-one-field-based-on-uniqueness-with-another-field/64025/1 "2016-10-26T15:40:40Z")

</div>

Sorry if the title doesn't make much sense, I'll try to explain. I have an API service that logs the version of the client as well as the customer ID on every API request. Now I want to know which client versions are used the most, which can be done with a simple term aggregation on the client\_version field.

The problem with this is that some customers use the service much more heavily than others, so the results can be quite skewed towards heavy users. What I'd like to do is count unique occurrences of client\_version/customer\_id, and sum them up per client\_id. So basically count of customers for each client version. Does that make any sense? And is that possible with Kibana?

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [October 28, 2016, 9:54pm UTC](https://discuss.elastic.co/t/count-values-of-one-field-based-on-uniqueness-with-another-field/64025/2 "2016-10-28T21:54:41Z")

</div>

Hi Benjamin... dang, I've spent 20 minutes trying to figure out if this is possible, and I still can't work it out. I'm looping in another engineer to see if this can be done.

Thanks,  
CJ

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [October 28, 2016, 9:59pm UTC](https://discuss.elastic.co/t/count-values-of-one-field-based-on-uniqueness-with-another-field/64025/3 "2016-10-28T21:59:38Z")

</div>

You mentioned client\_version, customer\_id, and client\_id. I'm a little confused about the distinction of customer\_id and client\_id. Could you explain this some more? And could you share a couple example documents?

Thanks,  
CJ

---

<div class="post-metadata">

**Author:** ![cjcenizal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjcenizal/32/11216_2.png) [@cjcenizal](https://discuss.elastic.co/u/cjcenizal)\
**Post date:** [October 28, 2016, 10:49pm UTC](https://discuss.elastic.co/t/count-values-of-one-field-based-on-uniqueness-with-another-field/64025/4 "2016-10-28T22:49:43Z")

</div>

I have an idea... how about you make a Data Table with a Bucket Terms Aggregation on the client\_version field? And then you can make the Metrics Aggregation a Unique Count on the client\_id field. Each row in the table will show you how many unique requests were made for each client\_version. Does this help?

CJ

---

<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:** [July 6, 2017, 1:35pm UTC](https://discuss.elastic.co/t/count-values-of-one-field-based-on-uniqueness-with-another-field/64025/5 "2017-07-06T13:35:11Z")

</div>

Closed on July 6, 2017, 1:35pm UTC


