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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
JDU
Helper I
Helper I

Urgent assistance: Calculate the moving average of a measure

Dear friends, I would like to ask for your kind assistance in solving the following problem:

The last column of the following image is the monthly average of each month calculated from the DAX Average measure (column 3/column 4).

 

Captura PBI.png

And what I need to do is to get the quarterly and semi-annual moving average of that measure (last column).

 

Example: (366+349+328)/3 = 347.6 ; (349+328+362)/3 = 343.3 and so on (idem with semester)

and (366+349+328+362+339+345)/6

 

I tried some solutions with SUMX and DATEINSPIRIOD but it always gives me a wrong number.

 

Thanks for your assistance.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JDU 

You can refer to the following example.

The sample data table

vxinruzhumsft_0-1675651890215.png

And The Average has been created in the table

vxinruzhumsft_2-1675651989651.png

Create two measures in table

quarterly = 
var _filter=FILTER(ALLSELECTED('Table'),EOMONTH('Table'[Date],0)<=EOMONTH(MAX('Table'[Date]),0))
var _top3=TOPN(3,_filter,[Date],DESC)
return DIVIDE(SUMX(_top3,ROUND([Average],0)),3)

semi-annual = 
var _filter=FILTER(ALLSELECTED('Table'),EOMONTH('Table'[Date],0)<=EOMONTH(MAX('Table'[Date]),0))
var _top6=TOPN(6,_filter,[Date],DESC)
return DIVIDE(SUMX(_top6,ROUND([Average],0)),6)

Output

vxinruzhumsft_1-1675651951307.png

Best Regards!

Yolo 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

4 REPLIES 4
Anonymous
Not applicable

Hi @JDU 

You can refer to the following example.

The sample data table

vxinruzhumsft_0-1675651890215.png

And The Average has been created in the table

vxinruzhumsft_2-1675651989651.png

Create two measures in table

quarterly = 
var _filter=FILTER(ALLSELECTED('Table'),EOMONTH('Table'[Date],0)<=EOMONTH(MAX('Table'[Date]),0))
var _top3=TOPN(3,_filter,[Date],DESC)
return DIVIDE(SUMX(_top3,ROUND([Average],0)),3)

semi-annual = 
var _filter=FILTER(ALLSELECTED('Table'),EOMONTH('Table'[Date],0)<=EOMONTH(MAX('Table'[Date]),0))
var _top6=TOPN(6,_filter,[Date],DESC)
return DIVIDE(SUMX(_top6,ROUND([Average],0)),6)

Output

vxinruzhumsft_1-1675651951307.png

Best Regards!

Yolo Zhu

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

 

FreemanZ
Super User
Super User

hi @JDU 

 

seems not difficult. could you paste your sample dataset, ideally in EN?

Greg_Deckler
Super User
Super User

@JDU See if this helps: Better Rolling Average - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Thank you very much Greg for your collaboration, I did not know that solution, very useful, however, the result is not the expected one, it is very close but not correct.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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