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
EvanWright
Regular Visitor

Moving Average Measure

Hello,

 

I need help with a Moving Average. I have read through many of the other messages, but I can't seem to get this one to work. I need to know the moving average of the Count by Steam,Target pairing using the WeekStart to advance the average.

 

His is a Sample of the data I am working with.

 

StreamTargetWeekStartCount
Marketafi4/10/20165
Marketafi5/15/2016415
Marketafi5/22/20162255
Marketafi6/12/2016494
Marketafi7/10/20168
Marketami4/10/20165
Marketami5/15/2016367
Marketami5/22/20162256
Marketami6/12/2016494
Marketami7/10/20168
Marketari4/3/2016128
Marketari4/10/2016132
Marketari4/17/2016114
Marketari4/24/20162085
Marketari5/1/2016565
Marketari5/8/2016460
Marketari5/15/201631
Marketari5/22/20168
Marketari5/29/2016174
Marketari6/5/2016175
Marketari6/12/201667
Marketari6/19/201653
Marketari6/26/20168
Marketari7/3/2016382
Marketari7/10/2016213
COMMafi4/10/20165
COMMafi5/15/2016415
COMMafi5/22/20162255
COMMafi6/12/2016494
COMMafi7/10/20168
COMMami4/10/20165
COMMami5/15/2016367
COMMami5/22/20162256
COMMami6/12/2016494
COMMami7/10/20168
COMMari4/3/2016128
COMMari4/10/2016132
COMMari4/17/2016114
COMMari4/24/20162085
COMMari5/1/2016565
COMMari5/8/2016460
COMMari5/15/201631
COMMari5/22/20168
COMMari5/29/2016174
COMMari6/5/2016175
COMMari6/12/201667
COMMari6/19/201653
COMMari6/26/20168
COMMari7/3/2016382
COMMari7/10/2016213
1 ACCEPTED SOLUTION
Phil_Seamark
Microsoft Employee
Microsoft Employee

Try this measure.  I've assumed your table is called 'Stream' and this calculates for 3 weeks (the -21 days)

 

Moving Average = 
		AVERAGEX(
			DATESINPERIOD(
				'Stream'[WeekStart],
				LASTDATE('Stream'[WeekStart]) ,
				 -21 , 
				 DAY),
			CALCULATE(sum('Stream'[Count]))
			)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

View solution in original post

4 REPLIES 4
EvanWright
Regular Visitor

That worked perfectly thank you so much!

Hi @EvanWright,

 

Great to hear the problem got resolved! Could you accept the corresponding reply as solution to help others who may have similar issue easily find the answer and close this thread?Smiley Happy

 

Regards

v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @EvanWright,

 

Have you tried the formula provided by Phil_Seamark? It should work in your scenario. If you still have any issue, feel free to post it out here.Smiley Happy

 

Regards

Phil_Seamark
Microsoft Employee
Microsoft Employee

Try this measure.  I've assumed your table is called 'Stream' and this calculates for 3 weeks (the -21 days)

 

Moving Average = 
		AVERAGEX(
			DATESINPERIOD(
				'Stream'[WeekStart],
				LASTDATE('Stream'[WeekStart]) ,
				 -21 , 
				 DAY),
			CALCULATE(sum('Stream'[Count]))
			)

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.