round
Description
Returns a number rounded to the nearest integer or to a specified number of
decimal places.
For example, 1.5 becomes 2 and 8.1 becomes 8.
Syntax
Like many functions in DataPrime, round supports two notations, function and method. These interchangeable forms allow flexibility in how you structure expressions.
- Function notation
- Method notation
round(number: number, digits: number?): number
(number: number).round(digits: number?): number
Arguments
| Name | Type | Required | Description |
|---|---|---|---|
number | number | true | The value to round |
digits | number | false | Number of decimal places to round to. Defaults to 0 (whole numbers) |
Example
Use case: Round averages for discrete counts
Compute the average number of online users and round to a whole number for clarity.
Example: 569.5 becomes 570.
Use case 2: Round latency values for readability
When analyzing traces, average latency values may have long decimal places. Use round with 2 digits for cleaner results.
Example data
{
"total_users_online": 1093
},
{
"total_users_online": 942
},
{
"total_users_online": 120
},
{
"total_users_online": 123
}
Example query
- Function notation
- Method notation
aggregate round(avg(total_users_online)) as average_users_online
aggregate total_users_online.avg().round() as average_users_online
Example output
{
"average_users_online": 570
}