# 🔢 Count duplicate elements in an array or list

**URL:** <https://community.glideapps.com/t/count-duplicate-elements-in-an-array-or-list/41313>\
**Category:** Community Resources\
**Created:** [April 27, 2022, 7:40pm UTC](https://community.glideapps.com/t/count-duplicate-elements-in-an-array-or-list/41313 "2022-04-27T19:40:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [April 27, 2022, 7:40pm UTC](https://community.glideapps.com/t/count-duplicate-elements-in-an-array-or-list/41313/1 "2022-04-27T19:40:18Z")

</div>

Hola!

This is not a feature request per se, instead, it is an easy solution to know how many times an element is in an array or list to use it later and create a ranking, a sorted list, etc.

Glide has many array plugins but I don’t know why something like it is missing when I needed it (it’s the reason I created this small code). Maybe the **Duplicated Items** plugin is closest to get it but it’s not enough.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/d/a/da6ec2f1f092edf68a3811ea6a0c45b2915a3d09.png)

Well, the case could be this:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/a/ea99563ca60ca746d085fe6bb1e73a627f3200be.png)

and in order to know how many times an element is in an array or list, you have to type this JS code in the JavaScript plugin

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/4/c/4c34cfac2051f9556044813c743c5d0d0edca778.png)

```auto
const arr=p1.split(",")

x= arr.filter(function(valor) {
       return valor == p2;
      }).length 

return x

```

… and that’s all folks! 💪

Maybe Glide can take this code and create a new plugin to increase their set of plugins and make the life easier to next developers in future without creating a relation/rollup . @SantiagoPerez@George_J

Saludos!

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [April 28, 2022, 1:43am UTC](https://community.glideapps.com/t/count-duplicate-elements-in-an-array-or-list/41313/2 "2022-04-28T01:43:55Z")

</div>

Ya…best you could do with existing columns is get length of full array of fruit. Then remove elements \> fruit. Then get length of new array. Then math column to subtract the two arrays.

Javascript is much cleaner, though.
