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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
EVIJ
Regular Visitor

calculate average for last 3 months for a calculated measure (percentage)

I would like to dynamically calculate the average percentage of the last 3 months .

in the matrix (screenshot) you can see the percentage per month which is a calculated measure. Is it possible to dynamically calculate the average of the last 3 months where the outcome is ((79,06+76,88+75,85)/3=) 77,26? 

 

EVIJ_0-1652350767561.png

 

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

Hi @EVIJ

 

I did some change on the formula provided by @johnt75 , i think that some context is not right and please try this:

Avg last 3 months =
VAR maxDate =
    MAX ( 'Date'[Date] )
VAR summaryTable =
    SUMMARIZE (
        FILTER (
            ALLSELECTED ( 'Date' ),
            [Date] > EOMONTH ( maxDate, -4 )
                && 'Date'[Date] <= EOMONTH ( maxDate, -1 )
        ),
        [Year_Month],
        "Existing measure", [Existing measure]
    )
RETURN
    AVERAGEX ( summaryTable, [Existing measure] )

 Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @EVIJ

 

I did some change on the formula provided by @johnt75 , i think that some context is not right and please try this:

Avg last 3 months =
VAR maxDate =
    MAX ( 'Date'[Date] )
VAR summaryTable =
    SUMMARIZE (
        FILTER (
            ALLSELECTED ( 'Date' ),
            [Date] > EOMONTH ( maxDate, -4 )
                && 'Date'[Date] <= EOMONTH ( maxDate, -1 )
        ),
        [Year_Month],
        "Existing measure", [Existing measure]
    )
RETURN
    AVERAGEX ( summaryTable, [Existing measure] )

 Pbix in the end you can refer.

Best Regards

Community Support Team _ chenwu zhu

 

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

johnt75
Super User
Super User

You can do something like

Avg last 3 months =
var maxDate = MAX('Date'[Date])
var summaryTable = ADDCOLUMNS( CALCULATETABLE( 
   SUMMARIZE( 'Date', 'Date'[Year month]),
   'Date'[Date] <= maxDate && 'Date'[Date] > EOMONTH(maxDate, -4)
), "@val", [Existing measure])
return AVERAGEX( summaryTable, [@val])

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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