Forum Discussion

alfredorhz's avatar
alfredorhz
Helper I
4 years ago
Solved

rolling 3 values sum

Hi Cummunity
Could please help me with rolling 3 values whitout dates, for example


Operation = value1/value2

Thanks a lot

 

 

 

  • Hi alfredorhz 
    Please refer to attached file

    3rolling = 
    VAR CurrentIndex = Data[Index]
    VAR OnAndBeforeTable = FILTER ( Data, Data[Index] <= CurrentIndex )
    VAR Last3Table = TOPN ( 3, OnAndBeforeTable, [Index] )
    RETURN
        IF ( 
            COUNTROWS ( Last3Table ) = 3,
            DIVIDE ( 
                SUMX ( Last3Table, [value1] ),
                SUMX ( Last3Table, [value2] )
            )
        )