I have data where I need to calculate the standard deviation of units per category (apo key+ material key make a unique category for my data) per year (which in my case is observed as previous year (PY), current year (CY) and new year (NY) and is available in the column 'is year')
I have calculated the average using the following formula:
Average =
CALCULATE (AVERAGE (tab[units] ),
FILTER ('tab', 'tab'[Material - Key]=EARLIER( 'tab'[Material - Key]) && 'tab'[ISYEAR]=EARLIER('tab'[ISYEAR]) && 'tab'[APO Key]= EARLIER('tab'[APO Key]))
)
and now need to calculate standard deviation.
The STDEV.X uses the formula sqrt(sum(X-Xavg)^2/n) but my n has to change per category per year and so I cannot apply this straightaway. I have tried modifying the above formula for calculating average to calculate standard deviation too but it doesn't give the right values.
My dataset (the 'sd' column is what I want to get):
