Calculating the Moving Average

  • Last update:January 12, 2025
  • Overview

    Background

    Time moving average is a commonly used data smoothing method, which filters out short-term fluctuations and highlights long-term trends in data. In short, it involves averaging the data within a certain time window. For example, 5-day moving average, 10-day moving average, 30-day moving average, and 3-month moving average.

    For example, if the size of the time window is 3 months, you can calculate the 3-month moving average through the following steps.

    Assume Sales Amount from the first month to the fifth month are M1, M2, M3, M4, and M5 respectively.

    • Moving average for the first month = (M1)/1

    • Moving average for the second month = (M1 + M2)/2

    • Moving average for the third month = (M1 + M2 + M3)/3

    • Moving average for the fourth month = (M2 + M3 + M4)/3

    • Moving average for the fifth month = (M3 + M4 + M5)/3

    Expected Effect

    The yellow line shows the fluctuation of sales with months, featuring large fluctuations and many sharp steep parts.

    To better observe the trend of sales, you can use the 3-month moving average method. The following figure shows the processed line in blue.

    image 5.png

    Procedure

    Adding Data

    Sample data: Supermarket Sales Data.xlsx

    Create an analysis subject and upload the sample data.

    Component Creation

    1. Create a group table and drag Order Date and Sales into the table to calculate the sales in different years and months, as shown in the figure.

    image 1.png

    2. Calculate the moving average of sales in the past three months, as shown in the following figure.

    image 2.png

    Formula Content

    Description

    Note

    WINDOW_AVG(SUM_AGG(Sales))

    The cross-row average of sales is calculated.

    WINDOW_AVG

    Parameter 2: []

    Data is not grouped.


    Parameter 3: Order   Date

    Data is sorted by Order Date (Year-Month) in the the ascending order.

    If no sorting method is specified, data is sorted in the ascending order by default.

    Parameter 4: [-2,0]

    Get the values from the previous two rows to the current row.

    Data from the two preceding rows to the current row is retrieved in the ranking order by Order Date (Year-Month), based on which the moving average is calculated.

    image 3.png

    3. Drag Moving Average of the Latest 3 Months into the chart, as shown in the following figure.

    image 4.png

    Expected Effect

    For details, see the previous section "Expected Effect."

    附件列表


    主题: Advanced Data Analysis
    Previous
    Next
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy