How can I sum numbers in an array?

Any quick tip on how to sum numbers in an array?


I would like to add a column that sums the numbers in the array of numbers in the last column. The array is a simple list of numbers, appended by the row.

Use a rollup column

1 Like

Nope. Doesn’t work… the sum option is not available.


Related: I would like the count of instances of an item from an array.


Interesting! :thinking:

I didn’t know that a Rollup column can count the items of array in each row, thanks for the tip!

However, your goal is the sum right?.. I think a customized JS code can do it easy:

This is my code by using an EC:

let len=p8.length;
let x=0, total =0;

while (x< len)  {
   total+= parseInt(p8[x]);
   x++ ;
return total

The problem here is that Glide’s JavaScript plugin does not support an array as input value so you must use another version or create a new version of that JavaScript plugin.

Maybe @david can read this note and carry out an improvement of his plugin to support these cases.

My version to work with this case runs on Replit:

Hope it helps you!

Feliz noche @Simon_Hill


What are you using to get that rolling total array? Seems like it’s being read as text.

1 Like


It is the reason why I use parseInt() in the code. This covers all cases so far.

I already know what you mean Thind, of course, if the arrays have numeric values the Rollup operation would have worked perfectly!!



This seems like an oversight. @mark @david?

1 Like

What is this Rolling total array column? How is it configured? Glide does not recognize it as an array of numbers.

Hola @BlakeWS

You can try with this JS code until Glide’s JavaScript plugin can support arrays as input values (parameter)

let  len=p8.length;
let  total=0;

for (let x= 0; x< len; x++) {
   if (p1==p8[x])  
      total ++
return total

My Source’s URL on Replit is :



@gvalero or:

return p8.filter(x => x === p1).length




I had forgotten the Filter() method :woozy_face:

Sometimes I like the old-programming school (C++) :grinning:

Gracias por el tip @david

1 Like

Thanks @gvalero & @david , it works great.


Hi David, thanks for taking the time.

Here is a quick video to explain… I think you’re right, Glide does not recognize the array is comprised of numbers.

Any quick fix?

1 Like

hmm, I’m surprised that isn’t working. Will be interested to see what the outcome is…

Interesting to note that the roll-up with sum works on the full array of 12 numbers. It stops working after splicing the array.

1 Like

yeah, kinda suggests that the Array Splice isn’t actually returning an array.


Hola Darren,

I think the Slice Array plugin is doing its job but the result is always a Text therefore, the Rollup column can’t sum text values.


yes, that’s what I meant. It’s not returning an array.

Yes! I bet the array columns all deal with arrays of ‘primitives’, which allows them to work on arrays of anything, but this causes the resulting array to lose type information (the Slice Array column ‘forgets’ what kind of array it’s slicing).

In regular programming, the solution to this is called Generics or polymorphism. I have some research projects to discuss with @Ivo_Elbert about this soon.