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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
amoatasem
Regular Visitor

Need to create Average of averages from another measure

Hi

 

I'm facing an issue where I want to create an average measure from another measure.

 

Basically, I'm trying to calculate 2 month average using the following: 

2 Mth Avg =
AVERAGEX (
    DATESINPERIOD ( 'DB'[Month], MAX ( 'DB'[Month] ), -2, MONTH ),
    CALCULATE ( SUM ( 'DB'[Value] ) )
)
 
which works fine, then I want to calculate 12 month average from the 2 month measure to further smooth the data points using:
12 Mth Avg =
AVERAGEX (
    DATESINPERIOD ( 'DB'[Month], MAX ( 'DB'[Month] ), -12, MONTH ),
    CALCULATE ( SUMX('DB',[2 Mth Avg])
)
)
 
But, I end up with the 12 month average of the previous 12 data points of value (68.15) while it should be (67.78) if it's calculated from the 2 mth avg column.
amoatasem_0-1711243154138.png

 

1 ACCEPTED SOLUTION
AnalyticPulse
Continued Contributor
Continued Contributor

12 Mth Avg = AVERAGEX ( DATESINPERIOD ( 'DB'[Month], MAX ( 'DB'[Month] ), -12, MONTH ), [2 Mth Avg] )
can you try this and let me know if this works

View solution in original post

6 REPLIES 6
talespin
Solution Sage
Solution Sage

hi @amoatasem 

 

SumVal is a measure SUM(Value)

 

Please see if this helps.

 

2MthAvg =
AVERAGEX(
            AvgAvg,
            CALCULATE( AVERAGEX(AvgAvg,[SumVal]), REMOVEFILTERS(), DATESINPERIOD( AvgAvg[Date], MAX(AvgAvg[Date]), -2, MONTH) )
)
 
12MthAvg =
AVERAGEX(
            AvgAvg,
            CALCULATE( AVERAGEX(AvgAvg,[2MthAvg]), REMOVEFILTERS(), DATESINPERIOD( AvgAvg[Date], MAX(AvgAvg[Date]), -12, MONTH) )
)
 
talespin_0-1711259445744.png

 

Hi @talespin 

Thank you for your reply.

For some reason I can't produce the same, when I try to calculate 2mnth Avg with the same equation I end up with the below:

amoatasem_0-1711276755183.png

 

AnalyticPulse
Continued Contributor
Continued Contributor

12 Mth Avg = AVERAGEX ( DATESINPERIOD ( 'DB'[Month], MAX ( 'DB'[Month] ), -12, MONTH ), [2 Mth Avg] )
can you try this and let me know if this works

It works, thank you very much!

great, you can give kudos and accept my reply as a solution 

amoatasem
Regular Visitor

To be more clear

This is what I want to achieve

YearMonthValue2 mth avg12 mth avg
2023December  57.85       61.68         68.94
2024January  59.04       58.45         68.07
2024February  59.74       59.39         67.33
2024March  70.33       65.04         66.89
2024April  73.25       71.79         67.00
2024May  73.71       73.48         67.14
2024June  72.39       73.05         67.39
2024July  69.43       70.91         67.51
2024August  67.20       68.32         67.10
2024September  68.38       67.79         66.92
2024October  69.40       68.89         67.10
2024November  68.18       68.79         67.30
2024December  66.71       67.45         67.78

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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