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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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