Forum Discussion

setis's avatar
setis
Post Partisan
6 years ago
Solved

Rolling average

Dear experts,   I am trying to calculate the rolling average of the last 12 months of the following measure:   Invoiced of CA = DIVIDE( [Invoiced];[Contract Assets LM] ; 0)   This is the inv...
  • MartynRamsden's avatar
    6 years ago

    Hi setis 

     

    You're almost there but your AVERAGEX is iterating over Calendar[Date], I think this needs to be Calendar[Month].

    Try this:

     

    Avrg Invoiced of CA 12M =
    CALCULATE (
        AVERAGEX (
            VALUES ( Calendar[Month] );
            [Invoiced of CA]
        );
        DATESINPERIOD (
            Calendar[Date];
            LASTDATE ( Calendar[Date] );
            -12;
            MONTH
        )
    )

     

    Best regards,

    Martyn

     

    If I answered your question, please help others by accepting it as a solution.

  • amitchandak's avatar
    6 years ago

    Values is used to use distinct values. Means if should group at day level

    Avrg Invoiced of CA 12M = 
    CALCULATE(
        AVERAGEX(VALUES(Calendar[Date]);[Invoiced of CA]) ;
        DATESINPERIOD(
            Calendar[Date];
            LASTDATE(Calendar[Date]);
            -12;
            MONTH
        )
    )

    Try

    Avrg Invoiced of CA 12M = 
    CALCULATE(
        AVERAGEX(VALUES(Calendar[Month-Year]);[Invoiced of CA]) ;
        DATESINPERIOD(
            Calendar[Date];
            LASTDATE(Calendar[Date]);
            -12;
            MONTH
        )
    )