Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
calvgo
Helper I
Helper I

Calculate rolling average with daily values information

I am trying to get the rolling 3 and/or 12 months average from the below sample data.

 

For this example, the average for each month is as follows in the pivot table:

Mar26
Apr8
May33
Jun47
Jul91
Aug61
Sep59
Oct146
Nov118

 

Therefore, I will get the three month rolling average for May = (26+8+33)/3 = 22; Nov = (59+146+118)/3 = 108 and so forth. 

I like to be able to adjust and calculate the rolling average to 12 months as well. 

 

Thanks. 

 

Sample Data

 

Closed DateDays taken
4/03/2021 0:0014
4/03/2021 0:0013
10/03/2021 0:000
11/03/2021 0:0065
11/03/2021 0:0014
15/03/2021 0:0017
22/03/2021 0:0032
26/03/2021 0:0052
1/04/2021 0:008
6/04/2021 0:0036
7/04/2021 0:000
14/04/2021 0:000
20/04/2021 0:000
22/04/2021 0:000
23/04/2021 0:003
23/04/2021 0:000
27/04/2021 0:004
27/04/2021 0:000
29/04/2021 0:0045
29/04/2021 0:000
3/05/2021 0:0096
3/05/2021 0:000
6/05/2021 0:0024
6/05/2021 0:009
10/05/2021 0:003
11/05/2021 0:000
12/05/2021 0:0090
13/05/2021 0:0016
17/05/2021 0:007
18/05/2021 0:00111
18/05/2021 0:0084
18/05/2021 0:007
27/05/2021 0:0020
28/05/2021 0:000
1/06/2021 0:0056
1/06/2021 0:0013
2/06/2021 0:0055
2/06/2021 0:0043
2/06/2021 0:0021
3/06/2021 0:0013
7/06/2021 0:00131
7/06/2021 0:0087
7/06/2021 0:0020
7/06/2021 0:000
8/06/2021 0:0039
9/06/2021 0:00261
9/06/2021 0:0061
9/06/2021 0:0056
9/06/2021 0:0030
9/06/2021 0:0021
9/06/2021 0:006
11/06/2021 0:000
17/06/2021 0:0014
18/06/2021 0:0065
18/06/2021 0:0031
18/06/2021 0:0025
22/06/2021 0:0039
24/06/2021 0:0037
29/06/2021 0:0056
5/07/2021 0:00108
5/07/2021 0:00140
6/07/2021 0:004
15/07/2021 0:0070
16/07/2021 0:0059
16/07/2021 0:0028
16/07/2021 0:0017
16/07/2021 0:000
19/07/2021 0:0090
22/07/2021 0:00125
22/07/2021 0:0087
22/07/2021 0:0049
23/07/2021 0:00154
23/07/2021 0:0080
23/07/2021 0:0078
26/07/2021 0:00153
26/07/2021 0:00136
26/07/2021 0:0053
27/07/2021 0:00166
27/07/2021 0:00103
29/07/2021 0:00125
30/07/2021 0:00172
3/08/2021 0:00156
5/08/2021 0:00100
5/08/2021 0:0030
10/08/2021 0:0082
10/08/2021 0:000
11/08/2021 0:007
12/08/2021 0:000
13/08/2021 0:0085
13/08/2021 0:0028
19/08/2021 0:0056
20/08/2021 0:00144
24/08/2021 0:0077
24/08/2021 0:000
25/08/2021 0:0014
30/08/2021 0:0054
30/08/2021 0:0010
31/08/2021 0:00165
31/08/2021 0:0084
1/09/2021 0:00141
1/09/2021 0:0082
1/09/2021 0:0043
1/09/2021 0:0026
2/09/2021 0:000
3/09/2021 0:0045
6/09/2021 0:00144
7/09/2021 0:000
9/09/2021 0:000
10/09/2021 0:0085
14/09/2021 0:006
17/09/2021 0:000
21/09/2021 0:00109
22/09/2021 0:00106
24/09/2021 0:0028
24/09/2021 0:000
27/09/2021 0:00152
27/09/2021 0:000
28/09/2021 0:00138
29/09/2021 0:0084
5/10/2021 0:00162
5/10/2021 0:00147
5/10/2021 0:00116
5/10/2021 0:000
8/10/2021 0:0014
15/10/2021 0:00148
15/10/2021 0:00260
15/10/2021 0:00106
15/10/2021 0:00101
15/10/2021 0:00414
21/10/2021 0:00191
21/10/2021 0:00175
21/10/2021 0:00141
21/10/2021 0:0063
2/11/2021 0:0082
2/11/2021 0:0042
8/11/2021 0:00181
8/11/2021 0:00172
8/11/2021 0:00153
8/11/2021 0:0097
9/11/2021 0:0097

 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @calvgo 

Try to create measures like this:

Rolling 3 month = 
DIVIDE(
CALCULATE(
    SUM('Table'[Days taken]),
    FILTER(ALL('Table'),
    EOMONTH('Table'[Closed Date],0)<=EOMONTH(MAX('Table'[Closed Date]),0)&&EOMONTH('Table'[Closed Date],0)>EOMONTH(MAX('Table'[Closed Date]),-3)
    )),
    3)
Rolling 12 month = 
DIVIDE(
CALCULATE(
    SUM('Table'[Days taken]),
    FILTER(ALL('Table'),
    EOMONTH('Table'[Closed Date],0)<=EOMONTH(MAX('Table'[Closed Date]),0)&&EOMONTH('Table'[Closed Date],0)>EOMONTH(MAX('Table'[Closed Date]),-12)
    )),
    12)

Result:

vangzhengmsft_0-1641967462033.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

 

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

View solution in original post

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @calvgo 

Try to create measures like this:

Rolling 3 month = 
DIVIDE(
CALCULATE(
    SUM('Table'[Days taken]),
    FILTER(ALL('Table'),
    EOMONTH('Table'[Closed Date],0)<=EOMONTH(MAX('Table'[Closed Date]),0)&&EOMONTH('Table'[Closed Date],0)>EOMONTH(MAX('Table'[Closed Date]),-3)
    )),
    3)
Rolling 12 month = 
DIVIDE(
CALCULATE(
    SUM('Table'[Days taken]),
    FILTER(ALL('Table'),
    EOMONTH('Table'[Closed Date],0)<=EOMONTH(MAX('Table'[Closed Date]),0)&&EOMONTH('Table'[Closed Date],0)>EOMONTH(MAX('Table'[Closed Date]),-12)
    )),
    12)

Result:

vangzhengmsft_0-1641967462033.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng

 

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

amitchandak
Super User
Super User

@calvgo , if you need avg of sum, with help from date table

 

Rolling 3 = calculate(AverageX(Values('Date'[MONTH Year]),CALCULATE(sum(Table[Days taken])),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

Rolling 12 = calculate(AverageX(Values('Date'[MONTH Year]),CALCULATE(sum(Table[Days taken])),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

 

You need simple avg

 

Rolling 12 = CALCULATE(Average(Table[Days taken),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

 

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

For some reason the calculation did not work properly based on your calculations. There are two parts to the calc. Can you show how you 1) perform the average for each month for 'days taken', and then 2) perform the 3/12 months rolling average from the part 1) monthly average? Can you load up the sample data and show the process please. 

 

Appreciate it.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.