Forum Discussion

C4L84's avatar
C4L84
Advocate II
4 years ago
Solved

TOTALYTD variable year

Hi   I need to pass thorugh a variable year end to TOTALYTD, however it's not working as hoped:      Running Total Spend = VAR _EndDate = FORMAT(MAX('FY end'[Date]), "DD/MM") RETUR...
  • tamerj1's avatar
    tamerj1
    4 years ago

    Hi C4L84 
    Here is the file with the solution https://we.tl/t-LZzcXfkSG3
    Your Mesure Code is

    Running Total Spend = 
    VAR _EndDate =
        MAX ( 'FY end'[Date] )
    VAR _CurrentYear =
        SELECTEDVALUE ( 'Calendar'[Financial year] )
    VAR _StartDate = 
        DATE ( _CurrentYear, MONTH ( _EndDate ), DAY ( _EndDate ) )
    VAR _CurrentDate =
        MAX ( 'Calendar'[Date] )
    VAR _Result =
        CALCULATE (
            SUM ( Sheet1[Spend] ),
            'Calendar'[Date] >= _StartDate,
            'Calendar'[Date] <= _CurrentDate
        )
    RETURN
        _Result