Forum Discussion

rsbin's avatar
rsbin
Community Champion
6 years ago
Solved

Moving Average -> Standard Deviation

Good Morning, Reaching out to the DAX experts out there.  I am trying to calculate the Standard Deviation of a Measure based on a 3 Day Moving Average (i.e. 3DayStdDev_EquipIDRatio).  My sample data...
  • Icey's avatar
    Icey
    6 years ago

    Hi rsbin ,

     

    How about using ALLSELECTED in the expression?

    3DayStdDev_EquipIDRatio =
    VAR CurrentIndex =
        MAX ( GeneralStatistics[GSIndex] )
    VAR PreviousIndex = CurrentIndex - 2
    VAR _table =
        SUMMARIZE (
            FILTER (
                ALLSELECTED (GeneralStatistics ),   ------------------edited
                GeneralStatistics[TotalVisits] <> 0
                    && GeneralStatistics[GSIndex] >= PreviousIndex
                    && GeneralStatistics[GSIndex] <= CurrentIndex
            ),
            [Date],
            "_EquipIDRatio", [EquipmentIDRatio]
        )
    RETURN
        STDEVX.P ( _table, [_EquipIDRatio] )

     

     

    Best Regards,

    Icey

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.