-
Dynamic Expression that abbreviates counting numbers from 1,000 up to billions
Hello there!
Right now I am trying to get into expressions and dynamic projects. I kind of got into the basics and a quick google search helps most of the time. But this seems like a tough nut to crack (or this is so easy that nobody needs to ask for help, who knows). Anyway:
I’ve set up a counter using a text layer that is linked to a point control’s x value so that the numbers go higher than the 1,000,000 limit that a normal slider would offer.
I need those Numbers to be abbreviated dynamically, meaning:
Up to 999 -> 999 (do nothing)
1,000 -> 1.0K (divide by 1,000)
1,000,000 -> 1.0M (divide by 1,000,000)
1,000,000,000 -> 1.0B (divide by 1,000,000,000)
I came up with
num= Math.round(thisComp.layer("NUMBER CONTROLLER").effect("Point Control")("Point")[0])/1000; num.toFixed(1) + 'K';which works fine for thousands, but obviously doesn’t work with hundreds, millions and billions. I could make 4 text + point control layers and let them count up one after another and blend them into each other when they reach their limit, but it would be cleaner to use an expression.
How do I tell After Effects to count the digits and divide it by the right amount depending on the digit count? Am I overthinking this?
Thanks!