Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
gopu99
New Member

YOY Difference help

Hi i have a data which will be refreshed timely

Tuition account Year
50texas2020-2021
100texas2021-2022
150texas2022-2023
200penstate2023-2024
250penstate2024-2025
300perdue2025-2026
350perdue2026-2027
400perdue2027-2028

i want to calculate the year on year change in Tuition Fee based on the Account 
i tried to create a date table but it didnt work 

Currently trying with this DAX Formula

YoY Growth =
VAR CurrentYearFee = SUM(Sheet1[Tuition ])
VAR PreviousYearFee =
    CALCULATE(
        SUM(Sheet1[Tuition ]),
        FILTER(
            ALL(Sheet1), (VALUE(Sheet1[ Year]) - 1)
        )
    )
RETURN
IF(ISBLANK(PreviousYearFee), 0, (CurrentYearFee - PreviousYearFee) / PreviousYearFee)
when i use this formul it is returning all 0 in all the rows
Please let me know any changes or things i can do to solve this thank you.

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

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
    )

vyiruanmsft_0-1692069415036.png

Best Regards

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

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
    )

vyiruanmsft_0-1692069415036.png

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
gopu99
New Member

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.