Rounds a numeric input field to the nearest integer, with an optional method to set the rounding type.
Parameter | Type | Required | Default | Description | |
---|---|---|---|---|---|
as | string | optional[a] | Same name as input field | The output name of the field to round. | |
field [b] | string | required | The names of the field to round. | ||
how | string | optional[a] | 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 | ||||
[a] Optional parameters use their default value unless explicitly set. |
Hide omitted argument names for this function
Omitted Argument NamesThe argument name for
field
can be omitted; the following forms of this function are equivalent:logscaleround("field")
and:
logscaleround(field="field")
These examples show basic structure only.
round()
Examples
Basic Rounding
round(myvalue)
Round a number to the nearest integer using standard math rules. Numbers greater than 0.5 are rounded up, numbers lower than 0.5 are rounded down.
Step-by-StepStarting with the source repository events
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% 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
The round()
rounds a number to the nearest
integer. To format a number, or round to a specific decimal
accuracy, use format()
.
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; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% 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. The format()
rounds a number to a specific decimal accuracy. To round a number
to the nearest decimal, use round()
.
Rounding within a Timechart
timechart(function=max(value))
| round(_max, how=floor)
Round a field and display using a Time
chart
.
Starting with the source repository events
- flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% 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; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% 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
Using the floor
parameter to a function always rounds down a number. This is
useful when displaying information in a time chart as all numbers
reolved to their base value which can make the differences between
values easier to distinguish when used on a graph.