Expression Library

Number Counter

Applied to the “source text” property of a text layer, creates an automatic increasing number counter between two numerical values. (As with many expressions, there are several ways to achieve the effect via code, and I’ve included two different approaches here: the first allows you to achieve the number counter effect with commas, without keyframing a start and end number, but is not written to accommodate $ or % symbols; the second enables the use of those symbols, but requires an intermediate point controller effect to be applied.)

Code Sample

Hover over the code and click the copy button.

				
					//Code 1 (for number with comma but no $ or %)//

startCount = 0;
endCount = 11689; // or whatever number you choose
countDur = 10;
s = "" + Math.round(linear(time,0,countDur,startCount,endCount));


if (s.length > 3){
s.substr(0, s.length -3) + "," + s.substr(-3);
}else{
s
}

//Code 2 (for number with commas and $ or % symbols)//

s = "" + Math.round(effect("Point Control")("Point")[0]);
s.replace(/\B(?=(\d{3})+(?!\d))/g, ",");