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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

3 Year Average per Month

Hi All,

 

I am trying to work out an average of X Value over the previous 3 years, not including the current year, by month and then filter by site. In my actual data I have 30+ sites.

My table looks like this:

SiteMonthMonth NoYearDateAverage Windspeed
Bicker FenJan1202401/01/20247.912230769
Bicker FenFeb2202401/02/20246.938166667
Bicker FenMar3202401/03/20246.656153846
Bicker FenJan1202101/01/20216.51
Bicker FenFeb2202101/02/20217.2
Bicker FenMar3202101/03/20216.4
Bicker FenJan1202201/01/20226.4
Bicker FenFeb2202201/02/20229.5
Bicker FenMar3202201/03/20225.7


I've tried  a few different ways like average for windspeed where year is <2024 etc but to no luck.

 

Thanks in Advance,
M

1 ACCEPTED SOLUTION
suparnababu8
Super User
Super User

Hi @Anonymous 

 

Try with this measure

AverageWindspeedLast3Years = 
CALCULATE(
    AVERAGEX(
        VALUES('Table'[Date]),
        'Table'[Average Windspeed]),
    FILTER(
        'Table',
        'Table'[Year] < YEAR(TODAY()) &&
        'Table'[Year] >= YEAR(TODAY()) - 3),
    ALLEXCEPT('Table', 'Table'[Site], 'Table'[Month], 'Table'[Month No])
)

 

Let me know if it works

View solution in original post

3 REPLIES 3
suparnababu8
Super User
Super User

Hi @Anonymous 

 

Try with this measure

AverageWindspeedLast3Years = 
CALCULATE(
    AVERAGEX(
        VALUES('Table'[Date]),
        'Table'[Average Windspeed]),
    FILTER(
        'Table',
        'Table'[Year] < YEAR(TODAY()) &&
        'Table'[Year] >= YEAR(TODAY()) - 3),
    ALLEXCEPT('Table', 'Table'[Site], 'Table'[Month], 'Table'[Month No])
)

 

Let me know if it works

Anonymous
Not applicable

Hi @suparnababu8,

This worked perfectly! Thank you 🙂

danextian
Super User
Super User

Hi @Anonymous 

Create a year table, relate it to your fact and create this measure:

Average = 
AVERAGEX (
    ADDCOLUMNS (
        SUMMARIZE (
            --create a table of years wherein the years are from current year -3 to current year - 1
            --note: if there are only two years in the current context, the sum of avg windspeed will be divided  by two as well, one if one...etc
            FILTER (
                ALL ( Years ),
                Years[Year]
                    >= MAX ( Years[Year] ) - 3
                    && Years[Year] < MAX ( Years[Year] )
            ),
            Years[Year]
        ),
        "Windspeed", CALCULATE ( SUM ( 'Table'[Average Windspeed] ) )
    ),
    [Windspeed]
)

danextian_0-1727437524943.png

 

Mar 2024: 5.7+6.4 = 12.1/2 = 6.05

Please see attached sample pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.