🔢 Count duplicate elements in an array or list

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.

Well, the case could be this:
image

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

const arr=p1.split(",")

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

return x

… and that’s all folks! :muscle:

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!

3 Likes

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.

3 Likes