# `floor`

## Description

Returns the largest integer less than or equal to a number. For example, `1.5` becomes `1`, and `8.1` becomes `8`.

## Syntax

Like many functions in DataPrime, `floor` supports [two notations](https://coralogix.com/docs/dataprime/language-reference/functions-reference/index.md), **function** and **method** notation. These interchangeable forms allow flexibility in how you structure expressions.

```dataprime
floor(number: number): number
```

```dataprime
(number: number).floor(): number
```

## Arguments

| Name   | Type   | Required | Description                        |
| ------ | ------ | -------- | ---------------------------------- |
| number | number | **true** | A numeric expression to round down |

## Example

**Use case: Calculate required SaaS licenses**

When averaging license usage over time, results may include decimals. Since you cannot buy fractional licenses, `floor` ensures the result is rounded down to the nearest whole number.

### Example data

```json
{
    "total_licenses": 100,
    "licenses_in_use": 31,
    "timestamp": "2024-10-10T21:00:00Z"
},
{
    "total_licenses": 100,
    "licenses_in_use": 35,
    "timestamp": "2024-10-11T21:00:00Z"
},
{
    "total_licenses": 100,
    "licenses_in_use": 22,
    "timestamp": "2024-10-12T21:00:00Z"
},
{
    "total_licenses": 100,
    "licenses_in_use": 54,
    "timestamp": "2024-10-13T21:00:00Z"
}
```

### Example query

```dataprime
aggregate floor(avg(total_licenses)) as licenses_needed
```

```dataprime
aggregate total_licenses.avg().floor() as licenses_needed
```

### Example output

```json
{
    "licenses_needed": 35
}
```
