Rounding to 2 decimal places
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 01:16 AM
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
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 01:45 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 02:03 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 02:13 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-09-2020 01:26 AM
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.