ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Math.round((a/b*100)) But if "0" become "text"

FAQ   •   VIEW ALL
 Math.round((a/b*100)) But if "0" become "text" on Jul 11, 2018 at 12:09:21 pm

Hi!

We have made this soccer template. It shows the shot accuracy in digits by dividing shots on goal with shots taken.
But if there are 0 shots the text layer saiz "NAN". We tried to get it to say "No shots taken". But AE gives this projects contains expression errors

```a=parseInt(thisComp.layer("n_ShotsOnGoal").text.sourceText); b=parseInt(thisComp.layer("n_Shots").text.sourceText); if(b == 0){ c = "No shots taken"; } else { c=Math.round((a/b*100))+"%"; }```

 Re: Math.round((a/b*100)) But if "0" become "text"on Jul 11, 2018 at 1:09:16 pm

Your expression works for me (I was surprised), but try changing this:

if(b == 0){

to this:

if(b == "0"){

Dan

 Re: Math.round((a/b*100)) But if "0" become "text"on Jul 11, 2018 at 2:15:58 pm

Thanks Dan.

Figured out that the error was from the bar graph. It took the value fom the text.

Now changing the expression in the scale property in the bargraph shape layer. So that the bar graph know that "No shots taken" equals "0"

```transition = 1 xa = 0; xb = parseInt(thisComp.layer("Shot_Percentage").text.sourceText); if(!xb){ xb=0; } y = 100; if(time < (inPoint+outPoint)/1){ ease(time,inPoint,inPoint+transition,[xa,y],[xb,y]); }else{ ease(time,outPoint -transition,outPoint,[xb,y],[xa,y]); } ```