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

ParameterTypeRequiredDefaultDescription
asstringoptional[a]Same name as input field The output name of the field to round.
field[b]stringrequired  The names of the field to round.
howstringoptional[a]round Method used to round the number.
  Valid Values
   ceilRound 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] Optional parameters use their default value unless explicitly set

[b] The argument name field can be omitted.

Omitted Argument Names

The argument name for field can be omitted; the following forms of this function 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 using standard math rules. Numbers greater than 0.5 are rounded up, otherwise they are rounded down.

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

Summary and Results

The round() rounds a number to the nearest decimal. To format a number, or round to a specific decimal accuracy, use format().

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 Time chart.

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

Summary and Results

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.