Forum Discussion

DEMDEJ's avatar
DEMDEJ
Frequent Visitor
3 years ago
Solved

Standard Deviation from 4 measured columns.... DARN!

Hi all!  I've researched so many sites (and previous answers) concerning computing standard deviation in PowerBI. I never knew it would be so difficult for me to do since Excel makes it SIMPLE!   ...
  • PiEye's avatar
    PiEye
    3 years ago

    Hi Demdej

     

    I have just realised that you wish to measure the standard deviation at a yearly granularity, not at the granularity of the data within. So over 5 data points

    Ie the calculation would look like this if we were to draw it out:

    SQRT(  ( (2016prod-avg)²+(2017prod-avg)²+....+(2020prod-avg)²)/5  )

     

    What we need for this are the "aggregateX" functions. These are probably easier to understand if you research "sumX" and "averageX" as they are better documented & used.

    Essentially, these functions will allow you to iterate across rows that you define:

    eg

    AverageX( Values([customerID]), sum(Sales)) will group by customer, calculate the sales for each then work out the average of all of those results. Giving you the average sales per customer.

     

    In your example we are going to use

    Year STDEV = STDEVX.P( VALUES(APY[Crop_Year]), [x years production])

    Where 

    x years production = CALCULATE(sum(APY[Production]),FILTER(APY,APY[Crop_Year]>= 2016))

     

    Plugging this into the table gives the result as manually calculated in excel.

    Result in PBI:

    calculation in Excel:

     

     

    Pi