# Rolling

The rolling function has the following syntax:

**`rolling(<variable>, <aggregation_method>, <type_of_range>, <range>, min_periods = 2)`**

<table><thead><tr><th width="224" align="center">Parameter</th><th align="center">Description</th><th width="213" align="center">Value</th><th align="center">Mandatory</th></tr></thead><tbody><tr><td align="center">Variable</td><td align="center">Represents the measurements of a sensor as a <a href="https://docs.ubidots.com/v1.6/reference/time-series">time series</a> of data points that vary over time. Also known as <a href="https://help.ubidots.com/en/articles/636672-plans-billing-what-are-dots">"dots"</a>, it is identified by a variable label.</td><td align="center">Variable label</td><td align="center">YES</td></tr><tr><td align="center">Aggregation method</td><td align="center">Computes the elements of a time series to return a single summary value.</td><td align="center"><span class="math">mean</span>, <span class="math">sum</span>, <span class="math">min</span>, <span class="math">max</span>, <span class="math">count</span></td><td align="center">YES</td></tr><tr><td align="center">Type of range</td><td align="center">Indicates whether a date range or a fixed number of elements is used to sample the time series.</td><td align="center"><span class="math">window</span> or <span class="math">values</span></td><td align="center">YES</td></tr><tr><td align="center">Range</td><td align="center"><p>The time window in which the function is computed.</p><p><strong>Note:</strong> Set the selected range for a "window" so it evenly divides the next range. For example, if you use minutes ("T"), the number <strong>n</strong> must evenly divide an hour ("H"). Available minute values are 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, and 30. Other values may produce unexpected results. The same applies to other ranges.</p></td><td align="center"><p>Available data ranges:</p><p>This is a <strong>positive integer</strong> that represents the number of observations used for each window, or a <strong>time range</strong> specified as follows:</p><p><span class="math">"nT"</span>: Every n minutes</p><p><span class="math">"nH"</span>: Every n hours</p><p><span class="math">"nD"</span>: Every n days</p></td><td align="center">YES</td></tr><tr><td align="center">Min periods</td><td align="center">Number of values needed to calculate the rolling aggregation. By default, it is set to 2, which is the minimum required.</td><td align="center"><code>min_periods = n</code>, where <strong>n</strong> is a positive integer.</td><td align="center">NO</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.ubidots.com/synthetic-variables/expressions/rolling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
