Forum Discussion

paolomint's avatar
paolomint
Icon for Helper III rankHelper III
5 years ago
Solved

Rolling sum not from zero

Hi, I'm workin on a running sum but this time I need something different: As first step I built  a standard rolling sum:   ROLLING SUM  = CALCULATE(sum(SCADENZE[IMPORTO]), filter(ALLSELECTED(SCAD...
  • V-lianl-msft's avatar
    V-lianl-msft
    5 years ago

    Hi paolomint ,

     

    Maybe I understand what you mean.Based on your description, you have two tables, and you want the amount retained in the "bank" table as the starting amount of the "flow" table.

    Try the measure.

    ROLL_FLOW =
    VAR base = [ROLL_BANK]
    VAR end_date =
        CALCULATE ( MAX ( Bank[Date] ), ALL ( Bank ) )
    RETURN
        IF (
            MAX ( FLOW[Date] ) > end_date,
            CALCULATE (
                SUM ( FLOW[VARIATION] ),
                FILTER ( ALLSELECTED ( FLOW ), FLOW[Date] <= MAX ( FLOW[Date] ) )
            ) + base,
            BLANK ()
        )

    Sample .pbix 

     

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