| **Animated Numbers with Comma - works for any numbers, positive and negative**
on Sep 19, 2016 at 6:36:38 pm |

Thought I'd share my expression for animating counting numbers with commas. This inserts commas appropriately for positive and negative numbers with no number size limit.

First add a slider control to your text layer. Then paste the expression in text source. If your number is less than a million, just use the slider numbers. If it's more, than set the countTotal to your desired number, and a slider value of 100 will output your number. You can keyframe multiple numbers above a million by taking the number you wish to go to, multiplying it by 100 and dividing by your countTotal.

You can also add text or characters before or after the number, like "$" for instance.

`countTotal=100;`

textBefore = "$";

textAfter = "";

n="" + Math.round(effect("Slider Control")("Slider")*countTotal/100);

s="";

for(i=0, l=n.length; i<l; i++){

if(s && s!="-" && (l-i)%3 ==0)

s+=",";

s += n[i];

}

textBefore+s+textAfter;