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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Employee
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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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