# Is it possible to get the length of the dataset of its own?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-get-the-length-of-the-dataset-of-its-own/263079>\
**Category:** Kibana\
**Tags:** vega\
**Created:** [February 3, 2021, 7:12am UTC](https://discuss.elastic.co/t/is-it-possible-to-get-the-length-of-the-dataset-of-its-own/263079 "2021-02-03T07:12:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![m-amano](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/m-amano/32/62977_2.png) [@m-amano](https://discuss.elastic.co/u/m-amano)\
**Post date:** [February 3, 2021, 7:12am UTC](https://discuss.elastic.co/t/is-it-possible-to-get-the-length-of-the-dataset-of-its-own/263079/1 "2021-02-03T07:12:02Z")

</div>

I am using Elasticsearch v.7.10.2 and Vega version is v.4.3.0.

I tried the code below to get the size of the dataset itself and got an error.

```auto
"data": [
  {
   "name": "dataset1",
   "values": [{...},{...}],
   "transform":[
    {"type":"formula", "expr":"length(data('dataset1'))", "as":"length"}
    ]
  },

```

the error message

```auto
Cannot read property 'length' of null

```

Is there any other way to know the length of the dataset itself?

---

<div class="post-metadata">

**Author:** ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)\
**Post date:** [February 4, 2021, 4:44pm UTC](https://discuss.elastic.co/t/is-it-possible-to-get-the-length-of-the-dataset-of-its-own/263079/2 "2021-02-04T16:44:20Z")

</div>

You should be able to use something like `hits.total` that gets returned from the query to ES itself. Does that work?

---

<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 4, 2021, 4:45pm UTC](https://discuss.elastic.co/t/is-it-possible-to-get-the-length-of-the-dataset-of-its-own/263079/3 "2021-03-04T16:45:01Z")

</div>

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