--- title: "Rolling Window Advanced Feature in Preset" slug: "rolling-functions" description: "Introduction, description, and usage of the Rolling Window advanced analytics feature in Preset Cloud." updated: 2023-04-07T18:10:59Z published: 2023-04-07T18:10:59Z canonical: "docs.preset.io/rolling-functions" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.preset.io/llms.txt > Use this file to discover all available pages before exploring further. # Rolling Functions ## Rolling Functions Rolling window functions allow you to create visualizations which are "summaries" of your data. For example, applying a mean rolling function to your dataset of individual sales allows you to see trends in how your sales are performing over a set rolling window, for example, 7 days. In instances when there is a lot of data variability, a rolling function will enable you to use a statistical value to represent the underlying values. **Note:** Rolling functions can only be used when the x-axis is set to a time or date-time column, as opposed to categorical. ## Setting up a Rolling Function 1. Start by expanding the drop down for **Advanced Analytics** 2. Specify the **Rolling Function** you'd like to apply. - **Mean**: The average of the values within the specified window. - **Sum**: The sum of the values within the specified window. - **Std**: This means *Standard Deviation*, which represents the dispersion of the data relative to its mean for the window. - **CumSum :** This means *Cumulative Sum*, which shows the cumulative data — it does not require period or min period values as it will calculate in a growing window. 3. Specify the number of Periods the function will take into account when calculating the rolling window - **Periods** is the number of time intervals which will be used by the rolling function. The time interval that is used for the period is the length of the **Time Grain** selected in the **Time** dropdown. - For example, if "days" is selected with a setting of 7 for "Periods", then the function will be based on 7 days. 4. Specify the **Min Periods** which should be taken into account when calculating the data point. **Tip**: this should be identical to **Periods** to ensure that every data point is calculated with the same window size. #### Example In this example, we are using the Vehicle Sales dataset and asking the question: "How is the sum of daily sales changing relative to the last 7 days of sales?" We have **order date** as our x-axis and the metric we are plotting is the **sum(sales).** Since our **Time grain** is set to *Day* when, we specify our *Periods* as 7 we are saying "Take the last **7 days** of data and apply the specified function to them to create a new data point." ![](https://cdn.document360.io/4749ddf8-aa05-4f3f-80e1-07a5d2d0f137/Images/Documentation/Rolling%20Window%20Mean.gif) ## Rolling Functions Rolling Function Options: - **Mean**: The average of the values within the specified window. - **Sum**: The sum of the values within the specified window. - **Std**: This means *Standard Deviation*, which represents the dispersion of the data relative to its mean for the window. - **CumSum :** This means *Cumulative Sum*, which shows the cumulative data — it does not require period or min period values as it will calculate in a growing window. --- ## Example ![Example_Rolling_Windows](https://cdn.document360.io/4749ddf8-aa05-4f3f-80e1-07a5d2d0f137/Images/Documentation/Example_Rolling_Windows.png) This case represents the number of new cases reported per day per country for the top 10 countries. New cases per day fluctuate day-by-day and, consequently, it is very difficult to see trends. Rolling functions support a better representation of data by representing the moving average in a 10-day period. This facilitates the easier identification of trends. ![Example_Rolling_Windows_1a](https://cdn.document360.io/4749ddf8-aa05-4f3f-80e1-07a5d2d0f137/Images/Documentation/Example_Rolling_Windows_1a.png) --- ## Cumulative Data Over a Period of Time With rolling windows, it is also possible to look at cumulative data over time. ![Rolling_Windows_Cumul_Data_OT](https://cdn.document360.io/4749ddf8-aa05-4f3f-80e1-07a5d2d0f137/Images/Documentation/Rolling_Windows_Cumul_Data_OT.png)