Skip to main content
Known Participant
August 11, 2022
Answered

Add percentage symbol % to text

  • August 11, 2022
  • 1 reply
  • 5232 views

Hi again guys 🙂

 

I am trying to add '%' to a text linked to a slider.

So, in my 'Source Text' I have the following expression:

effect("Slider Control")("Slider")

 

How can I add '%' at the end of my text? I have tried things like:

(effect("Slider Control")("Slider"))+%

but it does not work... 😞

 

It might be easy I just don't know how to code it.

 

 

Thank you!

Correct answer Rick Gerard

If you want an expression in a test layer to return the characters you enter, you need to put them in quotes. If you want two decimal points in your number, you need to extract the value from the Slider Control and add toFloor(2). You will end up with something like 24.50%. If you want no decimal points, the expression will look like this:

 

num = effect("Slider Control")("Slider").value;
num.toFixed(0) + "%";

 

 

1 reply

Rick GerardCommunity ExpertCorrect answer
Community Expert
August 11, 2022

If you want an expression in a test layer to return the characters you enter, you need to put them in quotes. If you want two decimal points in your number, you need to extract the value from the Slider Control and add toFloor(2). You will end up with something like 24.50%. If you want no decimal points, the expression will look like this:

 

num = effect("Slider Control")("Slider").value;
num.toFixed(0) + "%";

 

 

Known Participant
August 11, 2022

Awesome, thanks a million!