Can I do a sum of numbers in an Array (split text) column? The roll up is counting items in array, not summing it. I found a almost 18 months old thread but couldn’t find the solution.

I assume the rollup column automatically reads the content of each array element from a split text column as text, so you wouldn’t be able to “sum” it.

How did you generate the “FirstNameScore” column?

Why do you need that score to be split?

It’s part of the logic behind my game.

divide by 10 and take floor

How do I write this in Math column? Is it going to give me the sum in array?

Just for the reference here is the original formula used in google spreadsheet to calculate this value. Can’t figure out how to rewrite this in Glide.

=ARRAY_CONSTRAIN(ARRAYFORMULA(IF(IF(LEN(C5)>1, SUM(IFERROR(MID(C5,ROW(INDIRECT(“1:”&LEN(C5))),1)+0)), C5) = C5, 0, IF(LEN(C5)>1, SUM(IFERROR(MID(C5,ROW(INDIRECT(“1:”&LEN(C5))),1)+0)), C5))), 1, 1)

tell me what you need…

Circling back to the solution there first. I would say you can do it like this:

- Convert the original string to all lowercase
- Split text on the lowercase string
- Use a unique array column to get only unique letters
- Use a relation + rollup combo to get the total

Through your javascript I calculated the score using the letters.

Now the score for SanFrancisco came out to be 50 right?

My next logic is to add all digits of the score. In this case I have to do a sum of 5 + 0.

what is the highest possible score?

Already tried that but it does not give me the total of letters that are used twice. For example if a word is apple then your method will give me a score of just “A” “P” “L” “E” and not the other “P”.

No limit I believe. You can refer the google sheet formula I attached. It works perfectly in the sheet.

Is there anyway I can join these columns like this and put it in a math column? Tried but didn’t work though.

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

put as p1 result from my first script

You are a genius.

Next time explain your final goal for the problem. It is easier to give the right solution

@Uzo Can we change this JS in a way where if my number is a SINGLE DIGIT for example 9, then the answer should return as 0? I think we just need to add a IF ELSE statement on the script.

Try it. It is really easy to add that. I don’t think you need my help with that

Hahaha honestly I don’t. Without you, I will create Glides native IF ELSE column, and will end up creating so many of them.

One single add-on on your script will save my hours

if(p1<10){return(0)};

var n = p1, remainder, sumOfDigits = 0;

while(n)

{

remainder = n % 10;

sumOfDigits = sumOfDigits + remainder;

n = Math.floor(n/10);

}

return (sumOfDigits)