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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mcash
Helper I
Helper I

12 Month Averaging

I have the following data where I am trying to average the previous 12 months of Value and acheive the data in column "12 Mo Avg A" where the 12 month average is calculated regardless of the date slicer. All of the rolling average codes I've found on here returns column "12 Mo Avg B" where if I filter my date for a set period of time it will calculate the previous 12 months in each cell until the number of months within the filtered range is less than 12 and averages fewer and fewer months until it hits the minimum of the date range. Basically I need the calculation for measure Avg A to continue averaging back 12 months and only the visual to be filtered. In the table below the italicized numbers is an example of a filtered date range. I also have a Date table.

 

DateValue>>>12 Mo Avg A12 Mo Avg B 
1/1/202023.97    
2/1/202024.16    
3/1/202024.27    
4/1/202025.22    
5/1/202024.95    
6/1/202024.61    
7/1/202024.56    
8/1/202024.8    
9/1/202024.8    
10/1/202024.84    
11/1/202025.01    
12/1/202025.11    
1/1/202125.24    
2/1/202125.27    
3/1/202125.33    
4/1/202125.6    
5/1/202125.76    
6/1/202125.63    
7/1/202125.82    
8/1/202126.1    
9/1/202126.29    
10/1/202126.45    
11/1/202126.49    
12/1/202126.7    
1/1/202227.1    
2/1/202226.98    
3/1/202227.1 26.3427.10FILTERED RANGE
4/1/202227.36 26.4827.23 
5/1/202227.48 26.6327.31 
6/1/202227.35 26.7727.32 
7/1/202227.53 26.9127.36 
8/1/202227.6 27.0427.40 
9/1/202227.86 27.1727.47 
10/1/202228.09 27.3027.55 
11/1/202228.03 27.4327.60 
12/1/202228.15 27.5527.66 
1/1/202328.49 27.6727.73 
2/1/202328.42 27.7927.79 
3/1/202328.47 27.9027.90 
4/1/202328.86 28.0328.03 
5/1/202328.68 28.1328.13 
6/1/202328.64 28.2428.24 
7/1/202328.95 28.3528.35 
8/1/202328.84 28.4628.46 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @mcash,

I think you may need to create unconnected table as source for date filter. Then you can write measure expression to check the current date range and show the result of rolling 12 month records.

formula =
VAR SelectRange =
    VALUE ( NewTable[Date] )
VAR currDate =
    MAX ( Table[Date] )
VAR rollingAVG =
    CALCULATE (
        AVERAGE ( Table[Value] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date]
                >= DATE ( YEAR ( currdate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
                && [Date] <= currDate
        )
    )
RETURN
    IF ( currDate IN SelectRange, rollingAVG )

Regards,

Xiaoxin Sheng

View solution in original post

1 REPLY 1
Anonymous
Not applicable

HI @mcash,

I think you may need to create unconnected table as source for date filter. Then you can write measure expression to check the current date range and show the result of rolling 12 month records.

formula =
VAR SelectRange =
    VALUE ( NewTable[Date] )
VAR currDate =
    MAX ( Table[Date] )
VAR rollingAVG =
    CALCULATE (
        AVERAGE ( Table[Value] ),
        FILTER (
            ALLSELECTED ( Table ),
            [Date]
                >= DATE ( YEAR ( currdate ) - 1, MONTH ( currDate ), DAY ( currDate ) )
                && [Date] <= currDate
        )
    )
RETURN
    IF ( currDate IN SelectRange, rollingAVG )

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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