# 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">It shows 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's 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">Function where the elements of a time series are computed 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 set number of elements are 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 wich the function will be computed.</p><p>  </p><p><strong>NOTE</strong>: The selected range for a "window" should be set in a way that evenly divides the next range. For example, if using minutes ("T"), whatever the number <strong>n</strong> is, it has to evenly divide an hour ("H").  Available values for minutes are: 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30. Other values may render unexpected results. Same applies to other ranges.</p></td><td align="center"><p>Available data ranges:</p><p>this is a <strong>positive integer,</strong> representing the number of observations used for each window or a <strong>time range</strong> specified as follows:</p><p></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 mobile aggregation, by default it is set in 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>
