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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
kushsoni
New Member

Incorrect STDV.P in powerBI compared to excel STDV.P

All,

 

I am new to powerBI and DAX and was trying to calculate 5 weeks moving average and standard deviation. earlier I was doing everything in excel. 

 

below are the observations for the last 5 weeks and calculations done in excel:

wdateApplications submitAverageStdv.p
1/4/202024720255  
1/11/202021756257  
1/18/202018802997  
1/25/202017686517  
2/1/20201758652620110510.52753690

 

in power BI, the average comes out to be correct but STDV.P output is not matching

 

2/1/2020 - 

stdv.p = 993908

 

I have used the below formula for both average and standard deviation:

 

5 Weeks Moving average = CALCULATE(SUM('SQL Weekly'[application]),DATESINPERIOD('SQL Weekly'[w_date],LASTDATE('SQL Weekly'[w_date]),-35,DAY))/
CALCULATE(DISTINCTCOUNT('SQL Weekly'[w_date]),DATESINPERIOD('SQL Weekly'[w_date],LASTDATE('SQL Weekly'[w_date]),-35,DAY))
 
5 Weeks Moving STD.P = CALCULATE(STDEV.P('SQL Weekly'[application]),DATESINPERIOD('SQL Weekly'[w_date],LASTDATE('SQL Weekly'[w_date]),-35,DAY))
 
I further checked if I get an accurate sum for the last 5 weeks and it seems coming correct.
 
Any help will be great.
 
Thanks,
Kush

 

 

1 ACCEPTED SOLUTION
littlemojopuppy
Community Champion
Community Champion

Hi.  Your measures are overly complicated which is what's causing the error.  Try these...

Average Applications Submitted:=AVERAGE([Applications submit])

Standard Deviation Applications Submitted:=STDEV.P(Data[Applications submit])

Five Week Moving Average:=CALCULATE(
		[Average Applications Submitted],
		DATESINPERIOD(
			'Calendar'[Date],
			LASTDATE('Calendar'[Date]),
			-35,
			DAY
		)
	)

Five Week Moving Standard Deviation:=CALCULATE(
		[Standard Deviation Applications Submitted],
		DATESINPERIOD(
			'Calendar'[Date],
			LASTDATE('Calendar'[Date]),
			-35,
			DAY
		)
	)

 

Checking the calculations against Excel...

littlemojopuppy_0-1609086651311.png

What's in yellow is cutting and pasting your data.  Orange is me verifying the calculations in Excel.  Green is using the average and standard deviation measures above.  Hope this helps!

 

View solution in original post

1 REPLY 1
littlemojopuppy
Community Champion
Community Champion

Hi.  Your measures are overly complicated which is what's causing the error.  Try these...

Average Applications Submitted:=AVERAGE([Applications submit])

Standard Deviation Applications Submitted:=STDEV.P(Data[Applications submit])

Five Week Moving Average:=CALCULATE(
		[Average Applications Submitted],
		DATESINPERIOD(
			'Calendar'[Date],
			LASTDATE('Calendar'[Date]),
			-35,
			DAY
		)
	)

Five Week Moving Standard Deviation:=CALCULATE(
		[Standard Deviation Applications Submitted],
		DATESINPERIOD(
			'Calendar'[Date],
			LASTDATE('Calendar'[Date]),
			-35,
			DAY
		)
	)

 

Checking the calculations against Excel...

littlemojopuppy_0-1609086651311.png

What's in yellow is cutting and pasting your data.  Orange is me verifying the calculations in Excel.  Green is using the average and standard deviation measures above.  Hope this helps!

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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