Rounds a numeric input field to the nearest integer, with an optional method to set the rounding type.
Function Traits: FieldComputationFunction
, Transformation
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
as | string | optional | Same name as input field | The output name of the field to round. |
field [a] | string | required | The names of the field to round. | |
how | string | optional | round | Method used to round the number. |
Valid Values | ceil | Round up to the nearest whole number | ||
floor | Round down to the nearest whole number | |||
round | Standard rules; i.e. <0.5 rounds down, >0.5 rounds up | |||
The parameter name for field
can be omitted; the following forms are equivalent:
round("value")
and:
round(field="value")
round()
Examples
Basic Rounding
round(myvalue)
Round a number to the nearest decimal
Step-by-StepStarting with the source repository events
- flowchart LR; repo{{Events}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;
Rounds the number in myvalue
logscaleround(myvalue)
Event Result set
Rounding to n Decimal Places
format("%.2f", field=value)
To round a number to a specific number of decimal points, use
format()
rather than
round()
Starting with the source repository events
- flowchart LR; repo{{Events}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;
Round the field value to two decimal places.
logscaleformat("%.2f", field=value)
Event Result set
When using format()
, rounding is performed using standard math rules.
Rounding within a Timechart
timechart(function=max(value))
| round(_max, how=floor)
Round a field and display using a timechart
Step-by-StepStarting with the source repository events
- flowchart LR; repo{{Events}} 0[/Filter/] 1[/Filter/] result{{Result Set}} repo --> 0 0 --> 1 1 --> result style 0 fill:#ff0000,stroke-width:4px,stroke:#000;
Create a
Time Chart
usingmax()
as the aggregate function for the value field.logscaletimechart(function=max(value))
- flowchart LR; repo{{Events}} 0[/Filter/] 1[/Filter/] result{{Result Set}} repo --> 0 0 --> 1 1 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
Round the implied field from the aggregate
max()
using thefloor
option to round down the value.logscale| round(_max, how=floor)
Event Result set