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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
BibiC_2024
New Member

YOY $ and % variance from filtered values

Hi, can you help me with the formula to calculate variances based on filtered values?

I have this formula to calculate the variance with previous year, but how can I change it to be based on the current year vs filtered year?  Thanks in advance for your help!

 

YOY Var $ =
VAR __PREV_YEAR =
    CALCULATE(
        [Actual Short Value],
        DATEADD('Calendar_Ultimate'[Date], -1, YEAR)
    )
RETURN
    [Actual Short Value] - __PREV_YEAR
1 ACCEPTED SOLUTION
AmiraBedh
Most Valuable Professional
Most Valuable Professional

Try the following : 

YOY Var $ =
VAR CurrentYearValue = 
    CALCULATE(
        [Actual Short Value],
        FILTER(
            'Calendar_Ultimate',
            'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year])
        )
    )
VAR FilteredYearValue = 
    CALCULATE(
        [Actual Short Value],
        FILTER(
            'Calendar_Ultimate',
            'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year]) - N // N represents the number of years back you want to filter
        )
    )
RETURN
    CurrentYearValue - FilteredYearValue

 

And for the percentage variance :

YOY Var % =
VAR CurrentYearValue =
CALCULATE(
[Actual Short Value],
FILTER(
'Calendar_Ultimate',
'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year])
)
)
VAR FilteredYearValue =
CALCULATE(
[Actual Short Value],
FILTER(
'Calendar_Ultimate',
'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year]) - N // N represents the number of years back you want to filter
)
)
RETURN
DIVIDE(CurrentYearValue - FilteredYearValue, FilteredYearValue)

  

 

 

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

View solution in original post

1 REPLY 1
AmiraBedh
Most Valuable Professional
Most Valuable Professional

Try the following : 

YOY Var $ =
VAR CurrentYearValue = 
    CALCULATE(
        [Actual Short Value],
        FILTER(
            'Calendar_Ultimate',
            'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year])
        )
    )
VAR FilteredYearValue = 
    CALCULATE(
        [Actual Short Value],
        FILTER(
            'Calendar_Ultimate',
            'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year]) - N // N represents the number of years back you want to filter
        )
    )
RETURN
    CurrentYearValue - FilteredYearValue

 

And for the percentage variance :

YOY Var % =
VAR CurrentYearValue =
CALCULATE(
[Actual Short Value],
FILTER(
'Calendar_Ultimate',
'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year])
)
)
VAR FilteredYearValue =
CALCULATE(
[Actual Short Value],
FILTER(
'Calendar_Ultimate',
'Calendar_Ultimate'[Year] = SELECTEDVALUE('Calendar_Ultimate'[Year]) - N // N represents the number of years back you want to filter
)
)
RETURN
DIVIDE(CurrentYearValue - FilteredYearValue, FilteredYearValue)

  

 

 

 


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.