> ## Documentation Index
> Fetch the complete documentation index at: https://getlago.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Rounding

> Round a billable metric's measured quantity to a whole number or a chosen number of decimal places.

Rounding adjusts the result after Lago aggregates your events. For example, a metric that measures compute hours can return a whole number of hours or a value with two decimal places.

By default, Lago leaves the aggregated value unchanged.

## Rounding options

Set `rounding_function` to choose how Lago rounds the quantity:

* `ceil`: rounds up.
* `floor`: rounds down.
* `round`: rounds to the nearest value.

Use `rounding_precision` to set the number of decimal places.

## Precision

These examples use `rounding_function: round`.

| `rounding_precision` | Result for `123.4567` |
| - | - |
| Not set: round to a whole number | `123` |
| `2`: round to two decimal places | `123.46` |
| `-1`: round to the nearest ten | `120` |

## Example: compute hours

A billable metric measures 10.2 hours of compute usage during a billing cycle. With no precision set, each rounding option gives the following result:

| Rounding option | Result |
| - | - |
| No rounding | 10.2 hours |
| `ceil` | 11 hours |
| `floor` | 10 hours |
| `round` | 10 hours |

## Apply rounding

Once the metric is attached to a Plan, only its name, description and permitted filter changes can be updated. Set rounding before you attach the metric.

> [tab] Dashboard
>
> On the configuration page of your billable metric, enable rounding, select `ceil`, `floor` or `round`, and set an optional precision.

> [tab] API
>
> ```bash Round the aggregated value to 2 decimal places {14,15} theme={"dark"}
> LAGO_URL="https://api.getlago.com"
> API_KEY="__YOUR_API_KEY__"
>
> curl --location --request POST "$LAGO_URL/api/v2/billable_metrics" \
>   --header "Authorization: Bearer $API_KEY" \
>   --header 'Content-Type: application/json' \
>   --data-raw '{
>     "billable_metric": {
>       "name": "Storage",
>       "code": "storage",
>       "description": "Number of GB used",
>       "aggregation_type": "sum_agg",
>       "field_name": "gb",
>       "rounding_function": "round",
>       "rounding_precision": 2,
>       "recurring": false
>     }
>   }'
> ```

> [card] [Aggregation types](https://getlago.com/docs/v2/guide/billable-metrics/aggregation-types/overview.md)
>
> How the value is aggregated before rounding.

> [card] [Rates](https://getlago.com/docs/v2/guide/rate-cards/rates.md)
>
> Price the rounded quantity.

> [card] [Create a billable metric (API)](https://getlago.com/docs/v2/api-reference/billable-metrics/create.md)
>
> `POST /billable_metrics`

> [card] [Update a billable metric (API)](https://getlago.com/docs/v2/api-reference/billable-metrics/update.md)
>
> `PUT /billable_metrics/{code}`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.