Activity › Forums › Adobe After Effects Expressions › How do I add a + symbol in front of a percentage count increase?
-
How do I add a + symbol in front of a percentage count increase?
Posted by Jason Boekeloo on September 9, 2016 at 7:14 pmHey guys,
I want to add a plus symbol in front of the increasing percentage number but I’m not having any luck. Here is the This expression is working great for the percentage attached to a slider:
math.round(this.Comp.layer(“Slider”).effect(“Slider Control”)(“Slider”))+”%”
Any ideas? Thanks.
math.round(this.Comp.layer(“Slider”).effect(“Slider Control”)(“Slider”))+”%”Thomas Leitner replied 4 years, 6 months ago 3 Members · 9 Replies -
9 Replies
-
Dan Ebberts
September 9, 2016 at 10:09 pmLike this?
“+”+Math.round(thisComp.layer(“Slider”).effect(“Slider Control”)(“Slider”))+”%”
Dan
-
Jason Boekeloo
September 9, 2016 at 11:38 pmThanks for the reply, Dan, that was my guess as well. I will try it again unless I missed something but I don’t think it worked. Any other thoughts?
-
Dan Ebberts
September 10, 2016 at 12:54 am>I don’t think it worked
Please explain. Did it not do what you wanted? Did you get an error message?
Dan
-
Jason Boekeloo
September 10, 2016 at 6:45 pmWell now I feel a little silly. The last time I tried it I must have broke something else in the expressions accidentally because I tried again and it works! Problem solved thanks for the help.
-
Thomas Leitner
December 4, 2021 at 10:34 pmHi Dan & CC community,
so, I’m reviving a 5-year-old thread – registering a new account in the process – because I have a similar problem. I’m using a slider to display a number on a text layer. It’s for an election graphic where I want to display the results of the previous and current election. Everything works smoothly, except that I want it to show a plus sign, if the party has more votes than before and a “+/- 0” if it stayed exactly the same. The minus works by itself if the result is negative, but I can’t seem to figure out the rest on my own… Any help is very much appreciated.
Cheers,
Thomas -
Dan Ebberts
December 4, 2021 at 10:45 pmIt’s not clear (to me at least) what you’re asking. What are you comparing against? Also, I don’t understand the “+/- 0” part at all.
-
Thomas Leitner
December 5, 2021 at 12:37 pmI’m comparing the current election results against the previous one showing the changes with a number. While the maths automatically shows a minus in front of a loss of votes, I’d like to show a plus in front of a positive change. If nothing changed at all, I want it to literally show “+/- 0” (Instead of just 0).
-
Dan Ebberts
December 5, 2021 at 6:14 pmSomething like this then:
current = Math.round(effect("Current")("Slider"));
prev = Math.round(effect("Previous")("Slider"));
diff = current - prev;
if (diff < 0){
prefix = "-";
}else if (diff > 0){
prefix = "+";
}else{
prefix = "+/-";
}
prefix + Math.abs(diff)
-
Thomas Leitner
December 5, 2021 at 7:00 pmThe icon has struck again! You are the absolute best! Next to no adaptations and it fit my project and need perfectly! Your code even allowed me to figure out something else I couldn’t wrap my head around previously – THANK YOU SO MUCH, DAN!
Reply to this Discussion! Login or Sign Up