# Different counts of unique values in Kibana and CSV-export of the raw data

**URL:** <https://discuss.elastic.co/t/different-counts-of-unique-values-in-kibana-and-csv-export-of-the-raw-data/327654>\
**Category:** Kibana\
**Tags:** visualisation\
**Created:** [March 14, 2023, 12:24pm UTC](https://discuss.elastic.co/t/different-counts-of-unique-values-in-kibana-and-csv-export-of-the-raw-data/327654 "2023-03-14T12:24:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_Lie](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Mario\_Lie](https://discuss.elastic.co/u/Mario_Lie)\
**Post date:** [March 14, 2023, 12:24pm UTC](https://discuss.elastic.co/t/different-counts-of-unique-values-in-kibana-and-csv-export-of-the-raw-data/327654/1 "2023-03-14T12:24:33Z")

</div>

Hello Community!

I am using Kibana v 7.17.9

I count unique values for various log variables (Visualize-\>Metric-\>unique count). But the number of unique values differs slightly, depending on whether I use Kibana or export the same database as .csv-file and edit it with another statistics program (R, Python).

Example:

Total hits in Kibana 3567 -\> unique count of user\_id: 3267

Total count in .csv-file/Python 3567 -\> unique count of user\_id: 3275

Does anyone know reasons why this is happening?

Thanks a lot!

Mario

---

<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:** [April 11, 2023, 12:24pm UTC](https://discuss.elastic.co/t/different-counts-of-unique-values-in-kibana-and-csv-export-of-the-raw-data/327654/2 "2023-04-11T12:24:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![drewdaemon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewdaemon/32/97779_2.png) [@drewdaemon](https://discuss.elastic.co/u/drewdaemon)\
**Post date:** [April 12, 2023, 5:11pm UTC](https://discuss.elastic.co/t/different-counts-of-unique-values-in-kibana-and-csv-export-of-the-raw-data/327654/3 "2023-04-12T17:11:08Z")

</div>



---

<div class="post-metadata">

**Author:** ![drewdaemon](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/drewdaemon/32/97779_2.png) [@drewdaemon](https://discuss.elastic.co/u/drewdaemon)\
**Post date:** [April 12, 2023, 5:17pm UTC](https://discuss.elastic.co/t/different-counts-of-unique-values-in-kibana-and-csv-export-of-the-raw-data/327654/4 "2023-04-12T17:17:16Z")

</div>

Hi @Mario_Lie ! Sorry you didn't get a reply here sooner.

Under the hood, Kibana uses Elasticsearch's cardinality aggregation to generate that unique count number. Since Elasticsearch is a distributed data store, computing a true cardinality is difficult and precision requirements need to be balanced with cluster load.

See [this technical explanation](https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-metrics-cardinality-aggregation.html#_counts_are_approximate) for specific details, including the actual algorithm ( [HyperLogLog++](https://static.googleusercontent.com/media/research.google.com/fr//pubs/archive/40671.pdf)) that is being used.

Does this help?

---

<div class="post-metadata">

**Author:** ![Mario\_Lie](https://avatars.discourse-cdn.com/v4/letter/m/439d5e/32.png) [@Mario\_Lie](https://discuss.elastic.co/u/Mario_Lie)\
**Post date:** [April 13, 2023, 10:05am UTC](https://discuss.elastic.co/t/different-counts-of-unique-values-in-kibana-and-csv-export-of-the-raw-data/327654/5 "2023-04-13T10:05:50Z")

</div>

Hi @drewdaemon! Thanks a lot for your response and the links. That was exactly the information I needed.
