Forum Discussion

erikm's avatar
erikm
Frequent Visitor
5 years ago
Solved

Issue with displaying rolling totals

Hi, I am trying to accomplish the following scenario: User selects one date (that is the end date of a selection) The beginning of the date range is automatically set to January 1st of the previo...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi erikm 

    Try If function, I update the measure.

    balance RT =
    VAR _EndtDay =
        SELECTEDVALUE ( 'Calendar'[Date] )
    VAR _StartDay =
        DATE ( SELECTEDVALUE ( 'Calendar'[YEAR] ) - 1, 01, 01 )
    RETURN
        IF (
            MAX ( Movements[Year] ) * 100
                + MAX ( Movements[Month] )
                <= SELECTEDVALUE ( 'Calendar'[YEAR] ) * 100
                    + SELECTEDVALUE ( 'Calendar'[Month] ),
            CALCULATE (
                SUM ( Movements[balance] ),
                FILTER (
                    ALL ( Movements ),
                    Movements[MeasureDate] >= _StartDay
                        && Movements[MeasureDate] <= _EndtDay
                        && Movements[Year] = MAX ( Movements[Year] )
                        && Movements[Month] <= MAX ( Movements[Month] )
                )
            ),
            BLANK ()
        )

    Result is as below.

    Best Regards,

    Rico Zhou

     

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