Skip to main content
Participant
March 10, 2022
Answered

Custom format script - percentage with 2 decimal places

  • March 10, 2022
  • 1 reply
  • 3168 views

What would I enter in the Custom Format Script field if I want a number to appear as a percentage with 2 decimal places? So, for example, if 8 is written in the field, it shows up as 8.00%. I found this:

 

if (event.value) event.value+="%"; 

 

which shows 8 as 8%, but what do I couple it with to show 8.00%? 

 

Thanks,

Sarah 

Correct answer Nesa Nurani

Use this:

var x = Number(event.value);
if(event.value)
event.value = x.toFixed(2)+"%";

1 reply

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
March 10, 2022

Use this:

var x = Number(event.value);
if(event.value)
event.value = x.toFixed(2)+"%";

S.KWONAuthor
Participant
March 10, 2022

Works beautifully, thanks so much Nesa!!