Rounding to n Decimal Places

Query

flowchart LR; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[/Filter/] result{{Result Set}} repo --> 1 1 --> 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; %%{init: {"flowchart": {"defaultRenderer": "elk"}} }%% repo{{Events}} 1[/Filter/] result{{Result Set}} repo --> 1 1 --> result style 1 fill:#ff0000,stroke-width:4px,stroke:#000;
    logscale
    format("%.2f", field=value)

    Rounds the field value to two decimal places.

  3. Event Result set.

Summary and Results

When using format(), rounding is performed using standard math rules. The format() rounds a number to a specific decimal accuracy.

Note

To round a number to the nearest integer, use round(). See Basic Rounding.