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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
CatherineWang
Frequent Visitor

how to calculate moving average in different week

Hello,everyone!

 

I need your help! I need to calculate 3-4 values average based on week no.,The week may not be continuous (some of the weeks may not have value):
Case 1: less than 3 values, not calculated.
Case 2: 3 values, 3 values shall be calculated.
Case 3: more than 3 values, only the last 4 values shall be calculated.
For example: one size had value on week2351/2349/2346, that means week is not continuous, it only calculated 3 values. Another example is that Week2352/2351/2350/2349/2348/2347, only calculate the last 4 weeks value.

CatherineWang_0-1704948811985.png

 

How could I get the result by DAX? Has anyone got some ideas about it? 

Result may like as below:

CatherineWang_0-1704959544630.png

 

 

2 REPLIES 2
VijayP
Super User
Super User

@CatherineWang 

For any Time Intelligence you must have a proper date dimension Table.

to get weekly average you can use this formula

AVERAGEX(
                  DATESINPERIOD(
                                              DateDim[Date], StartDate[Datedim[Date]),-7,Day),Measure on which moving average

                                                                                                                          required)




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Thanks for your reply!

Because the week is not continuous sometimes, so I need each size the last 3-4 values to calculate average.Some values in continuous 4 weeks, some are in  10 weeks, only 4 weeks had value.The example as mentioned above!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors