# How to improve the accuracy of Unique Count metric in Kibana

**URL:** https://discuss.elastic.co/t/how-to-improve-the-accuracy-of-unique-count-metric-in-kibana/239012
**Category:** Kibana
**Created:** [June 28, 2020, 1:35pm UTC](https://discuss.elastic.co/t/how-to-improve-the-accuracy-of-unique-count-metric-in-kibana/239012 "2020-06-28T13:35:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pk.241011](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pk.241011/32/86285_2.png) [@pk.241011](https://discuss.elastic.co/u/pk.241011)
#### Post date: [June 28, 2020, 1:35pm UTC](https://discuss.elastic.co/t/how-to-improve-the-accuracy-of-unique-count-metric-in-kibana/239012/1 "2020-06-28T13:35:05Z")

</div>

Hi,

I am seeing some differences in the counts.

Background:

- Number of documents: 1,384,896
- Unique counts of fields A, B and C are reported as : 3641, 3791, 3799
- With `{"precision_threshold":40000}` Unique counts of fields A, B and C : 3637, 3791, 3789

The actual expected values are : 3638, 3791, 3791.

I tried to put a filter so as to reduce the number of documents from which the unique counts is taken. But it made no difference.

Will throwing more hardware at it help?

---

<div class="post-metadata">

### Author: ![aaron-nimocks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aaron-nimocks/32/73965_2.png) [@aaron-nimocks](https://discuss.elastic.co/u/aaron-nimocks)
#### Post date: [June 28, 2020, 10:54pm UTC](https://discuss.elastic.co/t/how-to-improve-the-accuracy-of-unique-count-metric-in-kibana/239012/2 "2020-06-28T22:54:15Z")

</div>

> **[Cardinality aggregation | Elasticsearch Reference](https://www.elastic.co/docs/reference/aggregations/search-aggregations-metrics-cardinality-aggregation)**
>
> A single-value metrics aggregation that calculates an approximate count of distinct values. Assume you are indexing store sales and would like to count...

Guess you have read that.

Depending on what you are doing exactly you can use Vega to get exact counts and create a metric visualization.

I swapped all of our metrics over to Vega due to this reason. But if your count is extremely high then it might not work.

---

<div class="post-metadata">

### Author: ![pk.241011](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pk.241011/32/86285_2.png) [@pk.241011](https://discuss.elastic.co/u/pk.241011)
#### Post date: [June 29, 2020, 1:04am UTC](https://discuss.elastic.co/t/how-to-improve-the-accuracy-of-unique-count-metric-in-kibana/239012/3 "2020-06-29T01:04:37Z")

</div>

That is kind of sad. As we are trying to use it more we are finding more limitations. We cannot use it now for one of our most important metrics, e.g. [First pass yield](https://en.wikipedia.org/wiki/First_pass_yield#:~:text=First%20pass%20yield%20(FPY)%2C,out%20of%20an%20individual%20process.).

---

<div class="post-metadata">

### Author: ![pk.241011](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pk.241011/32/86285_2.png) [@pk.241011](https://discuss.elastic.co/u/pk.241011)
#### Post date: [June 29, 2020, 2:29am UTC](https://discuss.elastic.co/t/how-to-improve-the-accuracy-of-unique-count-metric-in-kibana/239012/4 "2020-06-29T02:29:00Z")

</div>

Tried with number of shards equals one and number of replicas set to zero. Still no luck on improving the error margin.

---

<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 27, 2020, 2:29am UTC](https://discuss.elastic.co/t/how-to-improve-the-accuracy-of-unique-count-metric-in-kibana/239012/5 "2020-07-27T02:29:01Z")

</div>

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