Forum Discussion

yogiceg's avatar
yogiceg
Frequent Visitor
1 year ago
Solved

Power BI - Rolling average for every month

Hi Experts,

Kindly assist how to make rolling average in power BI for the below excel made data. Need to make visualization with rolling average. Advance thanks.

 

Year-MonthNumber of itemsSales valueAverage per monthRolling average
2024-01201809.009.00
2024-02292428.348.67
2024-03191648.638.66
2024-04292408.288.56
2024-05151147.68.37
2024-069626.898.12
2024-072434714.469.03
2024-0810878.78.99
2024-098556.888.75
2024-1014926.578.53
2024-115163.208.05
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi yogiceg ,

     

    You can try formula like below:

     

    MEASURE =
    AVERAGEX (
        FILTER (
            ALL ( 'SalesData' ),
            'SalesData'[Year-Month] <= MAX ( 'SalesData'[Year-Month] )
        ),
        [Average per month]
    )
    

     

     

    Best Regards,
    Adamk Kong

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 Replies

  • Hi yogiceg 

    To create a rolling average in Power BI based on your data, follow these steps:

    DAX:

     

    Rolling Average = 
    AVERAGEX(
        DATESINPERIOD(
            'Table'[Year-Month],
            LASTDATE('Table'[Year-Month]),
            -3,
            MONTH
        ),
        'Table'[Average per month]
    )

     

    Replace 'Table' with the actual name of your table in Power BI.

    • DATESINPERIOD defines the date range for the rolling average (3 months).
    • LASTDATE picks the latest date in the period.
    • AVERAGEX calculates the average over the date range

    You can adjust -3 to a different number of months (e.g., -6 for a 6-month rolling average).

    • Go to Report view.
    • Insert a Line Chart from the Visualizations pane.
    • Set up the fields for the chart:
      • Drag Year-Month to the Axis.
      • Drag the new Rolling Average measure to the Values.
      • Optionally, add Average per month to compare both the actual monthly average and the rolling average.
    • Format the Line Chart as needed (line color, thickness, etc.).
    • Adjust the Date axis for clarity (ensure it's in chronological order).

    This setup will display a rolling average that updates as each month is added to your data.

     

    Did I answer your question? Mark my post as a solution, this will help others!

    If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

    Kind Regards,
    Poojara
    Data Analyst | MSBI Developer | Power BI Consultant

  • yogiceg , Try using 

     

    Rolling Average =
    CALCULATE(
    AVERAGE('Table'[Average per month]),
    DATESINPERIOD(
    'Table'[Year-Month],
    LASTDATE('Table'[Year-Month]),
    -12,
    MONTH
    )
    )

  • yogiceg's avatar
    yogiceg
    Frequent Visitor

    Thanks for the reply. but, i am not getting the actual results. 

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi yogiceg ,

     

    You can try formula like below:

     

    MEASURE =
    AVERAGEX (
        FILTER (
            ALL ( 'SalesData' ),
            'SalesData'[Year-Month] <= MAX ( 'SalesData'[Year-Month] )
        ),
        [Average per month]
    )
    

     

     

    Best Regards,
    Adamk Kong

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • Hello yogiceg ,

     

    Here is the dax for you.

     

    Rolling_Average =
    CALCULATE(
        AVERAGE('Test'[Avg_per_Month]),
        FILTER(
            ALL(Test[Year-Month]),
            Test[Year-Month] <= MAX(Test[Year-Month])
        )
    )
     

     

    I hope it solves your query. Please mark this as solution if this helps .

     

    Cheers