Rounding to n Decimal Places

Query

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}} 0[/Filter/] result{{Result Set}} repo --> 0 0 --> result style 0 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. To round a number to the nearest decimal, use round().