Rounding to 2 decimal places

jasonedwards
Tera Contributor

Hi Community.

We use a formula indicator that calculates availability across all services

([[Month Availability - Uptime / By month SUM]] - [[Month Availability - Downtime / By month SUM]]) / [[Month Availability - Uptime / By month SUM]] * 100

We had less that an hour downtime last month out of a total of over 2.5million uptime minutes but the result shows as 100% unless we go to precision 3 e.g 99.998. This looks odd as all other %s are to precision 2.

Is it possible to show the value as 99.99% without it rounding up as reporting 100% isn't accurate / correct?

Thanks

 

7 REPLIES 7

Manoj Venkatesa
Mega Contributor

Hi Jasonedwards,

Not sure if this will help in your case but if there is a way to script the value then you can use below kinda code.

var newValue=3.4462;
var result= Math.round(newValue * 100) / 100);

// result will be 3.45

 

Anil Shewale
Mega Guru

Hi

You might want to ensure it is a floating point number first.

try following EXAmple:

var myHours = parseFloat(current.u_hours_worked);

myHours = myHours.toFixed(2);

 

refer thread for more:

https://www.servicenowguru.com/system-definition/controlling-decimal-field-places/

If it help mark helpful or correct 

Thanks and regards

Anil

Chander Bhusha1
Tera Guru

Hi Janson,

You can use the method toFixed() to round off to 2 digits.

var a = 99.9987;
var round = a.toFixed(2);

So the output would be:

99.99

Mark helpful and correct if it helps.

Thanks,

CB

How would I apply this to my formula indicator? ([[Month Availability - Uptime / By month SUM]] - [[Month Availability - Downtime / By month SUM]]) / [[Month Availability - Uptime / By month SUM]] * 100

I just keep return 100% to 2 decimals.