# Essql COUNT() vs Measure Unique (Canvas Metric)

**URL:** <https://discuss.elastic.co/t/essql-count-vs-measure-unique-canvas-metric/202319>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [October 4, 2019, 9:36am UTC](https://discuss.elastic.co/t/essql-count-vs-measure-unique-canvas-metric/202319 "2019-10-04T09:36:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [October 4, 2019, 8:47pm UTC](https://discuss.elastic.co/t/essql-count-vs-measure-unique-canvas-metric/202319/2 "2019-10-04T20:47:43Z")

</div>

Not 100% about this, but it's possible the 342 you get to be over a limited number of documents: [Canvas Metric Element: Unique count](https://discuss.elastic.co/t/canvas-metric-element-unique-count/166896/2). Also, the documentation seems to mention this default value: [https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html#essql\_fn](https://www.elastic.co/guide/en/kibana/current/canvas-function-reference.html#essql_fn).

From ES-SQL point of view, the first SELECT just retrieves some documents. The second one, on other hand, is running a `cardinality` aggregation on `reference_` field and does actually count the unique, non-null terms in that field. I would trust the second query, and would look for clues (like the one I mentioned above) on what kind of count does Canvas calculate on what set of documents.

---

_[View the full topic](https://discuss.elastic.co/t/essql-count-vs-measure-unique-canvas-metric/202319)._
