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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

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

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors