---
updatedAt: 2025-12-05T18:41:41.000Z
agentTools:
  projectIndex: https://docs.observeinc.com/llms.txt
---

# bin_size

```
bin_size() -> duration
```

Returns the size of the time bin that's being aggregated.

Typically used with time binning verbs [timechart](verb-timechart) or [align](verb-align). When used with [statsby](verb-statsby) returns the query window size.

# Domain

This is a scalar function (calculates a single output value for a single input row).

# Categories

* [Time](function#time-functions)

# Examples

<OpalCodeBlock code={
`timechart 10m, bin_size: bin_size(), group_by()
`}/>

Create a column named "bin\_size" that contains the size of the bin that timechart is aggregating upon. In this case, it should always be 10 minutes.

<OpalCodeBlock code={
`timechart 5m, frame(back: 20m), bin_size: bin_size(), group_by()
`}/>

Create a column named "bin\_size" that contains the size of the bin that timechart is aggregating upon. In this case, it should always be 20 minutes.

<OpalCodeBlock code={
`timechart events_per_minute: count() / to_minutes(bin_size()), group_by()
`}/>

Create a column named "events\_per\_minute" that shows the average number of events per minute.

<OpalCodeBlock code={
`statsby events_per_minute: count() / to_minutes(bin_size()), group_by()
`}/>

Return a dataset with column "events\_per\_minute" that calculates the number of rows per minute over the entire query window.