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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
Mburman-07
Helper I
Helper I

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 @Mburman-07 

 

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 @Mburman-07 

 

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

Hi @suparnababu8,

This worked perfectly! Thank you 🙂

danextian
Super User
Super User

Hi @Mburman-07 

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
March PBI video - carousel

Power BI Monthly Update - March 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors