Forum Discussion

gopu99's avatar
gopu99
Frequent Visitor
3 years ago
Solved

YOY Difference help

Hi i have a data which will be refreshed timely Tuition  account  Year 50 texas 2020-2021 100 texas 2021-2022 150 texas 2022-2023 200 penstate 2023-2024 250 penstate...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi gopu99 ,

    You can update the formula of measure [YoY Growth] as below, and check if that is what you want.

    YoY Growth = 
    VAR _selaccount =
        SELECTEDVALUE ( 'Sheet1'[account] )
    VAR _selyear =
        SELECTEDVALUE ( 'Sheet1'[Year] )
    VAR CurrentYearFee =
        SUM ( Sheet1[Tuition] )
    VAR _preyear =
        CALCULATE (
              MAX ( Sheet1[Year] ),
            FILTER (
                ALLSELECTED ( Sheet1 ),
                'Sheet1'[account] = _selaccount
                    && 'Sheet1'[Year] < _selyear
            )
        )
    VAR PreviousYearFee =
        CALCULATE (
            SUM ( Sheet1[Tuition] ),
            FILTER (
                ALLSELECTED ( Sheet1 ),
                'Sheet1'[account] = _selaccount
                    && 'Sheet1'[Year] =_preyear
            )
        )
    RETURN 
        IF (
            ISBLANK ( PreviousYearFee ),
            BLANK (),
            ( CurrentYearFee - PreviousYearFee ) / PreviousYearFee
        )

    Best Regards