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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
CLeDane
Frequent Visitor

Std. Dev. for a Monthly SUM

I need a measure that will calculate the std. deviation for a monthly sum. For instance, I have several costs posting to the same account in the first four months of this year. I would like to take the total monthly amount for each account and calulate a standard deviation of those 4 month totals.

 

Please see below screenshot (I cannot find where to attach .pbix file)Capture.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Here is the measure... however, you should be aware that it does take into consideration all filtering of the Calendar table. So, for instance, if in each cell of a visual you'll have a single month but a slicer will be set to only show, say, data for weekends for the months, the measure will honor this as well, that is, it'll calculate the SD among the months but only for data visible in the months, not full months.

 

[SD] =
var __sd =
	STDEVX.S(
		VALUES( 'Calendar'[Year-Month] ),
		[Total Amount]
	)
return
	// __sd could in certain circumstances
	// return NaN, so we need IFERROR to
	// account for such events
	IFERROR( __sd, 0 )

 

Bear in mind that for this to work you have to have a Calendar in the model (a proper Date table). Here's how you should handle time-intel in PBI:

 

https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/

 

Best

D

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Here is the measure... however, you should be aware that it does take into consideration all filtering of the Calendar table. So, for instance, if in each cell of a visual you'll have a single month but a slicer will be set to only show, say, data for weekends for the months, the measure will honor this as well, that is, it'll calculate the SD among the months but only for data visible in the months, not full months.

 

[SD] =
var __sd =
	STDEVX.S(
		VALUES( 'Calendar'[Year-Month] ),
		[Total Amount]
	)
return
	// __sd could in certain circumstances
	// return NaN, so we need IFERROR to
	// account for such events
	IFERROR( __sd, 0 )

 

Bear in mind that for this to work you have to have a Calendar in the model (a proper Date table). Here's how you should handle time-intel in PBI:

 

https://www.sqlbi.com/tv/time-intelligence-in-microsoft-power-bi/

 

Best

D

This worked perfectly! I just couldn't get that formula's reference logic down.

 

Thank you!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.