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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Community Champion
Community Champion

@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!:
DAX For Humans

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.