Forum Discussion

RayMundo00's avatar
RayMundo00
Regular Visitor
3 years ago
Solved

Average and Standard Deviation using Measures as arguments

Hi everyone, hope someone can help me. Context I need to monitor the consumptions of a certain substance in a certain equipment per month. The monitoring is for the last 3 months (Consumptions tabl...
  • AlexisOlson's avatar
    3 years ago

    You should be able to do this with AVERAGEX and STDEVX.S. These functions ignore blanks but include zeroes.

     

    This might work:

    AVERAGEX (
        {
            [Month -2],
            [Month -1],
            [Current Month],
            [Month +1],
            [Month +2],
            [Month +3]
        },
        [Value]
    )

    but you probably don't need separate measures for each month offset when something more like this should work:

    AVERAGEX (
        GENERATESERIES ( -2, 3 ),
        CALCULATE ( [Measure], DATEADD ( 'Date'[Date], [Value], MONTH ) )
    )

     

  • AlexisOlson's avatar
    AlexisOlson
    3 years ago

    You could switch between them.

     

    AVERAGEX (
        GENERATESERIES ( -2, 3 ),
        VAR _i = [Value]
        RETURN
            IF (
                _i <= 0,
                CALCULATE ( [SumCurrent], DATEADD ( 'Date'[Date], _i, MONTH ) ),
                CALCULATE ( [SumFuture],  DATEADD ( 'Date'[Date], _i, MONTH ) )
            )
    )