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
epicleo
Frequent Visitor

Calculating STDEV for most Recent 12-Months

Hello Everyone, 

As part of a larger calculation, I am trying to calculate standard deviation of sales for the most recent 12 Months using a DimDate table.

 

The problem I am having is figuring out how to calculate STDEV for the most recent 12 Months when a particular item has less then 12 months of sales history.  So, what I am attempting to do is calculate STDEV for each item up to the most recent 12 Months or as many months available given not all products have 12 months of history.

 

Your help is GREATLY appreciated!!

 

Thank you.

2 REPLIES 2
v-sihou-msft
Microsoft Employee
Microsoft Employee

@epicleo

 

In this scenario, you have to split all parts to get your "custom" std dev. Please refer to the solution in a similar thread below:

 

https://stackoverflow.com/questions/42605377/calculating-the-standard-deviation-from-columns-of-valu...

 

Regards,

@v-sihou-msft  Thank you for the info!!  The link you provided helped out, but my senario is a bit different.  In the example, the individule had to create his sample set by calculating the number of instances our ocurrances by multiplying the qty by frequency.  For me, my sample set is the sum of sales in the month.  In addiiton I include a date filter.  Here is what I came up with, but its not working well.  Can you provide any help?  Take care!!

 

 

ST_DEV = CALCULATE(
Var x_sum = SUM(iContractsChargebacks[ChargebackUnits])
Var mean = DIVIDE(x_sum,6)
VAR dev_sq_sum = POWER(x_sum- mean,2)
return
SQRT(dev_sq_sum/6),
FILTER(ALL(DimDate),
DimDate[Month ID]<=MAX(DimDate[Month ID])-1 &&
DimDate[Month ID]>=MAX(DimDate[Month ID])-6
)
)

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors