Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Fix My Millions – Trying to get numbers to display correctly

  • Fix My Millions – Trying to get numbers to display correctly

    Posted by Kieran Lefort on April 9, 2019 at 1:53 pm

    I’ve been trying to get this expression to work all day and, frankly, I have a headache. Apologies if I explain this badly; my brain is fried.

    I’m working in the latest version of AE CC 2019 and adapted this tutorial to deal with decimals (so, for example, an entry of 1500 returns a result of 1.5K instead of 2K):-

    https://youtu.be/yIJ057Yh91c

    I then further adapted it so it could handle numbers larger than the Slider Control’s limit of 1,000,000 by using an Angle Control as the source instead.

    The problem I have is I also need it work with numbers in the billions, but it falls apart in the millions. The highest number I can input before it breaks is 999,949. That returns a result of 999.9K. 999,950 – 999,998 returns 1000.0K. 999,999 makes the display go blank.

    1,000,000 dead-on is fine, returning 1M, but anythign between 1,000,000 and 1,099,999 returns 1.0.

    If I try to enter 1,000,000,000 (one billion), it returns 1000M.

    Hopefully this makes some sort of sense. Open to any suggestions. Please be gentle; I’m quite new at expressions and am well aware I’m probably trying to front up to Usain Bolt before I can walk. ????

    numSlider = effect("Angle Control")("Angle")/360;
    n = numSlider/1000;
    m = numSlider/1000000;
    b = numSlider/1000000000;
    v = numSlider;
    check = v % 1000;
    checkMillion = v % 1000000;
    checkBillion = v % 1000000000;
    //For numbers under 1000
    if (numSlider < 1000) numSlider;
    //For numbers in the thousands
    else if (check == 0 && numSlider < 1000000) Number(n) +"K";
    else if (numSlider > 1000 && numSlider < 999999) Number(n).toFixed(1) + "K";
    //For numbers in the millions
    else if (checkMillion == 0 && numSlider >= 1000000) Number(m) +"M";
    else if (numSlider > 1000000 && numSlider < 999999999) Number(m).toFixed(1) + "M";
    //For numbers in the billions
    else if (checkBillion == 0 && numSlider >= 1000000000) Number(b) +"B";
    else if (numSlider > 1000000000) Number(b).toFixed(1) + "B"

    Some contents or functionalities here are not available due to your cookie preferences!

    This happens because the functionality/content marked as “Google Youtube” uses cookies that you choosed to keep disabled. In order to view this content or use this functionality, please enable cookies: click here to open your cookie preferences.

    Kalleheikki Kannisto replied 7 years, 1 month ago 2 Members · 3 Replies
  • 3 Replies
  • Kalleheikki Kannisto

    April 10, 2019 at 7:19 am

    Depends on your exact application, but in most cases you can’t see the lower numbers so clearly that you actually need to use a single slider. It may be easier to have separate sliders, one for the billions, one for millions, one for thousands, and one for 0-999, each using its own 0-999 range. And even if you need the counting to slow down to arrive at a specific number, that can be relatively easily keyframed with those four sliders. That’s one option to consider.

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Kieran Lefort

    April 10, 2019 at 9:14 am

    Thanks for your reply.

    Maybe I wasn’t very clear, sorry: There’s no animation or counting. The number just needs to be displayed with a K, M or B depending on if it’s in the thousands, millions or billions. This is for a MOGRT to be used in Premiere by people with no AE experience, so if they were to type 4,6000,000,000 then the expression would automatically convert it to display as “4.6B”.

    After sleeping on it, I think I’ve just got carried away with my new expressions knowledge and tried to be too clever. ????I think I’ll replace it with a simple text box for the number (or a 1 – 999 slider) and a series of checkboxes or a slider for the K/M/B suffix.

  • Kalleheikki Kannisto

    April 11, 2019 at 8:05 am

    Yes, if there’s no need for accuracy in the number, that’s a more sensible approach: a slider for “magnitude” which gives you thousands, millions or billions.

    Kalleheikki Kannisto
    Senior Graphic Designer

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy