Rounds a numeric input field to the nearest integer, with an optional method to set the rounding type.

Function Traits: FieldComputationFunction, Transformation

ParameterTypeRequiredDefaultDescription
asstringoptionalSame name as input field The output name of the field to round.
field[a]stringrequired  The names of the field to round.
howstringoptionalround Method used to round the number.
  Valid ValuesceilRound up to the nearest whole number
   floorRound down to the nearest whole number
   roundStandard rules; i.e. <0.5 rounds down, >0.5 rounds up

[a] The argument name field can be omitted.

The parameter name for field can be omitted; the following forms are equivalent:

logscale
round("value")

and:

logscale
round(field="value")

round() Examples

Basic Rounding

Query
flowchart LR; repo{{Events}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result
logscale
round(myvalue)
Introduction

Round a number to the nearest decimal

Step-by-Step
  1. Starting with the source repository events

  2. 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

    logscale
    round(myvalue)
  3. Event Result set

Rounding to n Decimal Places

Query
flowchart LR; repo{{Events}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result
logscale
format("%.2f", field=value)
Introduction

To round a number to a specific number of decimal points, use format() rather than round()

Step-by-Step
  1. Starting with the source repository events

  2. 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.

    logscale
    format("%.2f", field=value)
  3. Event Result set

Summary and Results

When using format(), rounding is performed using standard math rules.

Rounding within a Timechart

Query
flowchart LR; repo{{Events}} 0[/Filter/] 1[/Filter/] result{{Result Set}} repo --> 0 0 --> 1 1 --> result
logscale
timechart(function=max(value))
| round(_max, how=floor)
Introduction

Round a field and display using a timechart

Step-by-Step
  1. Starting with the source repository events

  2. 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 using max() as the aggregate function for the value field.

    logscale
    timechart(function=max(value))
  3. 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 the floor option to round down the value.

    logscale
    | round(_max, how=floor)
  4. Event Result set