Answers.Body: <p>Here's my cheat sheet for numeric text animations like this:</p>
  
  <pre><code>slider = (effect("Slider Control")("Slider").value);
  tidying = (Math.round(slider * 100))/100;
  SourceText = "$" + tidying + "bn" +"\r" +"DEBTS";
  </code></pre>
  
  <p>the .value is sometimes needed to force AE to look at the slider as a number, not as an object.</p>
  
  <p>tidying is being done to round up to 2 decimal places</p>
  
  <p>\r gives a line break</p>
  
  <p>text is appended with +”text”+</p>
  
  <p>you can comment out some text   /* like this */</p>
  
  <p>So in the example above, you would get an output like this:</p>
  
  <pre><code>$5.23bn
  DEBTS
  </code></pre>
  
  <p>So for your specific example, try something like this:</p>
  
  <pre><code>slider = (effect("Slider Control")("Slider").value);
  tidying = (Math.round(slider * 10))/10;
  SourceText = tidying + "M views";
  </code></pre>
  
  <p>To specify showing a decimal place at all times (displaying "2.0" when your slider is set to "2"), use the "toFixed" function, like this:</p>
  
  <pre><code>slider = (effect("Slider Control")("Slider").value);
  tidying = ((Math.round(slider * 10))/10).toFixed(1);
  SourceText = tidying + "M views";
  </code></pre>
  
  <p>Screenshot:
  <a href="https://i.sstatic.net/toXvb.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/toXvb.png" alt="AE screenshot"></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-15T11:07:06.440Z
Answers.Text: Also, any way to keep the 0 when the number goes without decimal? Like 2.0 instead of 2
Answers.UserDisplayName: Apeiron_Sound
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-23T13:46:27.937Z
Answers.Text: yes, you can use "toFixed(1)" to round to show one decimal place at all times - so: 
  
  slider = (effect("Slider Control")("Slider").value);
  tidying = ((Math.round(slider * 10))/10).toFixed(1);
  SourceText = tidying + "M views";
Answers.UserDisplayName: tomh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-13T10:02:09.460Z
Answers.LastActivityDate: 2019-04-23T13:48:18.313Z
Answers.LastEditDate: 2019-04-23T13:48:18.313Z
Answers.UserDisplayName: tomh
Body: <p>I'm trying to work out a counter that simply goes like:</p>
  
  <p><strong>2.5M views</strong></p>
  
  <p>At the moment I've got this expression working along with a <em>Slider Control</em>:</p>
  
  <pre><code>var num = effect("Slider Control")("Slider")
  num = Comma(num) + "M views";
  [num]
  
  function Comma(number)
  {
  number = '' + Math.round(number);
  if (number.length &gt; 3)
  {
  var mod = number.length % 3;
  var output = (mod &gt; 0 ? (number.substring(0,mod)) : '');
  for (i=0 ; i &lt; Math.floor(number.length / 3); i++)
  {
  if ((mod == 0) &amp;&amp; (i == 0))
  output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
  else
  output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
  }
  return (output);
  }
  else return number;
  }
  </code></pre>
  
  <p>This though only makes my text layer go like:</p>
  
  <p><strong>2M views</strong></p>
  
  <p>I've tried already replacing the first line with:</p>
  
  <pre><code>effect("Slider Control")("Slider").value.toFixed(2)
  </code></pre>
  
  <p>But this adds a decimal followed by a comma normally, it doesn't work anyways on this expression but maybe it can help.</p>
  
  <p>Thanks in advance.</p>
  
Tags: <after-effects><after-effects-expressions>
Title: AE Counter Expression (0.0M views)
UserDisplayName: Apeiron_Sound
ThreadText: # AE Counter Expression (0.0M views)
  
  (Asked by: username_0 on 2019-04-12)
  
  I'm trying to work out a counter that simply goes like:
  
  **2.5M views**
  
  At the moment I've got this expression working along with a *Slider Control*:
  
  ```
  var num = effect("Slider Control")("Slider")
  num = Comma(num) + "M views";
  [num]
  
  function Comma(number)
  {
  number = '' + Math.round(number);
  if (number.length > 3)
  {
  var mod = number.length % 3;
  var output = (mod > 0 ? (number.substring(0,mod)) : '');
  for (i=0 ; i < Math.floor(number.length / 3); i++)
  {
  if ((mod == 0) && (i == 0))
  output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
  else
  output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
  }
  return (output);
  }
  else return number;
  }
  
  ```
  
  This though only makes my text layer go like:
  
  **2M views**
  
  I've tried already replacing the first line with:
  
  ```
  effect("Slider Control")("Slider").value.toFixed(2)
  
  ```
  
  But this adds a decimal followed by a comma normally, it doesn't work anyways on this expression but maybe it can help.
  
  Thanks in advance.
  
  **Tags:** after-effects, after-effects-expressions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-04-13. Score: 1 | Accepted answer
  
  Here's my cheat sheet for numeric text animations like this:
  
  ```
  slider = (effect("Slider Control")("Slider").value);
  tidying = (Math.round(slider * 100))/100;
  SourceText = "$" + tidying + "bn" +"\r" +"DEBTS";
  
  ```
  
  the .value is sometimes needed to force AE to look at the slider as a number, not as an object.
  
  tidying is being done to round up to 2 decimal places
  
  \r gives a line break
  
  text is appended with +”text”+
  
  you can comment out some text /\* like this \*/
  
  So in the example above, you would get an output like this:
  
  ```
  $5.23bn
  DEBTS
  
  ```
  
  So for your specific example, try something like this:
  
  ```
  slider = (effect("Slider Control")("Slider").value);
  tidying = (Math.round(slider * 10))/10;
  SourceText = tidying + "M views";
  
  ```
  
  To specify showing a decimal place at all times (displaying "2.0" when your slider is set to "2"), use the "toFixed" function, like this:
  
  ```
  slider = (effect("Slider Control")("Slider").value);
  tidying = ((Math.round(slider * 10))/10).toFixed(1);
  SourceText = tidying + "M views";
  
  ```
  
  Screenshot:
  [![AE screenshot](https://i.sstatic.net/toXvb.png)](https://i.sstatic.net/toXvb.png)
  
  > **Comments:**
  > **username_0**: Also, any way to keep the 0 when the number goes without decimal? Like 2.0 instead of 2  
  > **username_1**: yes, you can use "toFixed(1)" to round to show one decimal place at all times - so:   slider = (effect("Slider Control")("Slider").value); tidying = ((Math.round(slider * 10))/10).toFixed(1); SourceText = tidying + "M views";  
  
  ---
  
  