Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Need Help: Persistent Moving/Rolling Average

Is there a DAX formula to persist, or hold, the lastest value of the rolling/moving average whenever data points are over and to extend it thru time? 
  • Anonymous's avatar
    Anonymous
    7 years ago
    Anonymous I'm sorry for that.
    I'll try and see if I can get LastNonBlank to work. I propose an alternative solution. 
    Get the lastdate where price/box is not blank. Look up the price/box for that date.
    =
    VAR lastPriceDate =
        CALCULATE (
            MAX ( Table1[Date] );
            ALLEXCEPT ( Table1; Table1[Product] );
            NOT ( ISBLANK ( Table1[Price/Box] ) )
        )
    VAR LastPrice =
        CALCULATE (
            MAX ( Table1[Price/Box] );
            ALL ( Table1 );
            VALUES ( Table1[Product] );
            Table1[Date] = lastPriceDate
        )
    RETURN
        IF ( ISBLANK ( Table1[Price/Box] ); LastPrice; Table1[Price/Box] )



    Cheers,
    Pedro