# Sum an Array

**URL:** <https://community.glideapps.com/t/sum-an-array/65880>\
**Category:** Ask for Help\
**Created:** [September 7, 2023, 5:58pm UTC](https://community.glideapps.com/t/sum-an-array/65880 "2023-09-07T17:58:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darius\_Elijah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darius_elijah/32/62411_2.png) [@Darius\_Elijah](https://community.glideapps.com/u/Darius_Elijah)\
**Post date:** [September 7, 2023, 5:58pm UTC](https://community.glideapps.com/t/sum-an-array/65880/1 "2023-09-07T17:58:34Z")

</div>

![Screenshot 2023-09-07 at 19.54.46 (2)](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/a/8ac8c696d140dbc5b93cccb820be503c52ed0913.jpeg)  
Need to sum items in Car Services Array.  
Tried rollup column, the sum option is not available.  
tried js solutions available on the forum doesnt seem to work  
Perhaps i am missing something

```auto
var n = p1, remainder, sumOfDigits = 0;
while(n)
{
    remainder = n % 10;
    sumOfDigits = sumOfDigits + remainder;
    n = Math.floor(n/10);
}
return (sumOfDigits)

```

---

<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:** [September 7, 2023, 6:21pm UTC](https://community.glideapps.com/t/sum-an-array/65880/2 "2023-09-07T18:21:54Z")

</div>

> [@Darius\_Elijah](#):
>
> Need to sum items in Car Services Array.  
> Tried rollup column, the sum option is not available.

Hola!

Your **Car Services** (column) is not an Array, it’s a List.

To convert it to Array column use a Split Text column and then you can use a Rollup column with no problem.

Saludos!

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [September 7, 2023, 6:43pm UTC](https://community.glideapps.com/t/sum-an-array/65880/3 "2023-09-07T18:43:17Z")

</div>

A few comments:

- I agree with Gustavo. The “Car Services” column is a text column which contains comma-separated values. It’s not an array. As far as Glide is concerned a,b,c is one single string of text “a,b,c”.
- The column type is text, so even after applying a Split Text column to turn the string “a,b,c” into an array [a,b,c], the underlying elements of the arrays will be seen as text, and therefore the Roll Up column will probably only offer count and count unique (there is nothing to sum with text).
- If you want to be able to sum numbers, I think it would be better to gather numeric responses from your users in numeric columns.
- By any chance are you on a Pro plan? If so, this might be a good use case for the Glide AI Text to Number feature: feed text as the input, get number values as the output. Even though, the input here would be a text CSV, so I’m not exactly sure how that would work. I’m curious though.

---

<div class="post-metadata">

**Author:** ![Darius\_Elijah](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darius_elijah/32/62411_2.png) [@Darius\_Elijah](https://community.glideapps.com/u/Darius_Elijah)\
**Post date:** [September 7, 2023, 7:39pm UTC](https://community.glideapps.com/t/sum-an-array/65880/4 "2023-09-07T19:39:32Z")

</div>

The Car Services is dropdown, which is attached to

 ![Screenshot 2023-09-07 at 21.37.59 (2)](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/6/e/6e73aece527731afd9cae7236e2a66567a1f4cef.jpeg)  
with the services displaying in dropdown but the values are linked to the price.  
Manual input of prices is really the last option.  
Any other way to work around it?

---

<div class="post-metadata">

**Author:** ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)\
**Post date:** [September 7, 2023, 7:56pm UTC](https://community.glideapps.com/t/sum-an-array/65880/5 "2023-09-07T19:56:29Z")

</div>

I see. In the choice component, you could write the names of the services (or better, the Row IDs) instead of the prices. Turn the csv into an array, relate to your pricing table, and sum through the relation. Or pull in the prices with a lookup.

Bottom line: write the services instead of the prices, then fetch the prices with a relation.

---

<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:** [September 7, 2023, 9:57pm UTC](https://community.glideapps.com/t/sum-an-array/65880/6 "2023-09-07T21:57:06Z")

</div>

> [@nathanaelb](#):
>
> Bottom line: write the services instead of the prices, then fetch the prices with a relation.

This ☝
