# Counting the number of items in repeater

**URL:** <https://forum.wixstudio.com/t/counting-the-number-of-items-in-repeater/10291>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [May 23, 2023, 7:03pm UTC](https://forum.wixstudio.com/t/counting-the-number-of-items-in-repeater/10291 "2023-05-23T19:03:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tamirros](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tamirros/32/24396_2.png) [@tamirros](https://forum.wixstudio.com/u/tamirros)\
**Post date:** [May 23, 2023, 7:03pm UTC](https://forum.wixstudio.com/t/counting-the-number-of-items-in-repeater/10291/1 "2023-05-23T19:03:27Z")

</div>

Hi guys,

I am trying to provide a total count of items in the repeater but I also set the number of items to display through the dataset and then a button to load more items. I am struggling to get a total count not just the count of the max items it loaded in the first run. I set the number of items to display to 12, so when I use the code below, and I have more than 12 items to show, it will give me 12 until I load more items. any way to get the number in the first place?

```javascript
$w("#text1").text = $w("#repeater1").data.length.toString();

```

Thanks,  
Tamir

---

<div class="post-metadata">

**Author:** ![thomasj](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/thomasj/32/30791_2.png) [@thomasj](https://forum.wixstudio.com/u/thomasj)\
**Post date:** [May 23, 2023, 7:13pm UTC](https://forum.wixstudio.com/t/counting-the-number-of-items-in-repeater/10291/2 "2023-05-23T19:13:10Z")

</div>

Hi Tamir,

If you want the total count of items on a dataset connected to a repeater, you can use the [getTotalCount()](https://www.wix.com/velo/reference/wix-dataset/dataset/gettotalcount) method on the dataset.

Here’s a example of how it can be used:

```javascript
const totalCount = $w("#repeaterDataset").getTotalCount();

```

---

<div class="post-metadata">

**Author:** ![tamirros](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/tamirros/32/24396_2.png) [@tamirros](https://forum.wixstudio.com/u/tamirros)\
**Post date:** [May 24, 2023, 1:12am UTC](https://forum.wixstudio.com/t/counting-the-number-of-items-in-repeater/10291/3 "2023-05-24T01:12:23Z")

</div>

Thanks Thomas! From some reason it gave me an error message when I used the getTotalCount().  
I ended up query the data collection and then using the length attribute of the results from the query.
