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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
LUCASM
Helper IV
Helper IV

Year on Year difference without date table

I have a data set of annual figures
I am trying to calculate the Year on Year Difference and Year on Year Difference %

YearSales
201913023
202012003
202114976
202215534
202315956

 

The formula I have variations of is 

 

Value LY = 
VAR Prev_Year = CALCULATE ( MAX ( Forecast[Year] ),
            FILTER ( ALL ( Forecast[Year] ), Forecast[Year] = Forecast[Year] - 1 ) ) 

RETURN
CALCULATE ( [Total Value],
FILTER ( ALL ( Forecast ),
Forecast[Year] = Prev_Year ) )

 

but nothing seems to return a result for me I always get an empty result for Previous Year

I am trying to use it in a Matrix like below

Years across the top 

Values are This Year and Difference

2019201920202020202120212022202220232023
ValueDiff PreYrValueDiff PreYrValueDiff PreYrValueDiff PreYrValueDiff PreYr
13023 12003-10201496729621553456715956431

 

1 ACCEPTED SOLUTION
Bibiano_Geraldo
Super User
Super User

Hi @LUCASM ,
To calculate the Year on Year (YoY) Difference and YoY Difference % without a date table, you can use DAX measures:
Create a measure for the previous year’s value:

Value LY = 
VAR Prev_Year = MAX(Forecast[Year]) - 1
RETURN
CALCULATE(
    [Total Value],
    FILTER(
        ALL(Forecast),
        Forecast[Year] = Prev_Year
    )
)

Create a measure for the YoY Difference:

YoY Difference = 
[Total Value] - [Value LY]

Create a measure for the YoY Difference %:

YoY Difference % = 
DIVIDE([YoY Difference], [Value LY], 0)

This setup should give you the desired output with the values and their differences year over year.

Thank you!

View solution in original post

13 REPLIES 13
Ashish_Mathur
Super User
Super User

Hi,

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1731553784580.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur 
I was excited to try your file.
However, although your data works mine does not and I cant see why.
Ive added my test data to your file and renamed my tables and calculations to a suffix2. I am getting zeros everywhere and I cant see why.
Just as a thought, how do you get your calculated Date column with no hierachy?
Ive reattached your file with my data

 

Variance.pbix 

 

Amend the relationship

Ashish_Mathur_0-1731626837643.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Schoolboy error, how annoying!

Thank you for your quick responce

That my friend is so very helpful.
Love this...

DataNinja777
Super User
Super User

Hi @LUCASM ,

 

You already have many solutions 😀, but please note that it’s recommended to use a calendar table in your data model for year-on-year calculations. This approach ensures consistent handling of dates and leverages Power BI’s time intelligence functions for greater accuracy. 

 

Best regards,

I agree and in all my reports I have a date table.
In this instance as the data is only yearly data I considered this an overkill as no other calculations could be run over it.

Theres no quarterly, monthly, weekly or daily data available.
Should that change - Im not holding my breath, then of course a data table would be invaluable.
But it is a very wise comment, for which I thank you.

Bibiano_Geraldo
Super User
Super User

Hi @LUCASM ,
To calculate the Year on Year (YoY) Difference and YoY Difference % without a date table, you can use DAX measures:
Create a measure for the previous year’s value:

Value LY = 
VAR Prev_Year = MAX(Forecast[Year]) - 1
RETURN
CALCULATE(
    [Total Value],
    FILTER(
        ALL(Forecast),
        Forecast[Year] = Prev_Year
    )
)

Create a measure for the YoY Difference:

YoY Difference = 
[Total Value] - [Value LY]

Create a measure for the YoY Difference %:

YoY Difference % = 
DIVIDE([YoY Difference], [Value LY], 0)

This setup should give you the desired output with the values and their differences year over year.

Thank you!

lkalawski
Super User
Super User

Hi @LUCASM ,

Your variable Prev_Year calculates each year earlier than the maximum in the entire dataset - it does not take into account the selected year.

 

Please try this measures:

Total Value = 
SUM(Forecast[Sales])
Value LY = 
VAR __StartYear = 
MAX(Forecast[Year]) - 1

VAR __Result =
CALCULATE ( Sum(Forecast[Sales]),
FILTER ( ALL ( Forecast ),
Forecast[Year] = __StartYear ) )

RETURN
    __Result
Diff YoY = [Total Value] - [Value LY]

 

lkalawski_0-1731503420792.png

 

PBI_SuperUser_Rank@1x.pngMemorable Member | Former Super User
If I helped, please accept the solution and give kudos! 
Linkedin

 

Thank you for your help

mh2587
Super User
Super User

//1.Add an Index Column: Since we don’t have dates, add an index to simulate the year ordering. //This can be added in Power Query or DAX as a calculated column in Power BI.

//2.Calculate YoY Difference: Use DAX to create a measure for the YoY Difference, which will //subtract the previous year's sales from the current year's sales.

YoY Difference = 
    VAR CurrentYearSales = SELECTEDVALUE('Table'[Sales])
    VAR PreviousYearSales = 
        CALCULATE(
            SELECTEDVALUE('Table'[Sales]),
            'Table'[Index] = EARLIER('Table'[Index]) - 1
        )
    RETURN
        IF(NOT(ISBLANK(PreviousYearSales)), CurrentYearSales - PreviousYearSales)

//3.Calculate YoY Difference %: The YoY Difference % compares the difference relative to the //previous year's sales.

YoY Difference % = 
    VAR CurrentYearSales = SELECTEDVALUE('Table'[Sales])
    VAR PreviousYearSales = 
        CALCULATE(
            SELECTEDVALUE('Table'[Sales]),
            'Table'[Index] = EARLIER('Table'[Index]) - 1
        )
    RETURN
        IF(NOT(ISBLANK(PreviousYearSales)), (CurrentYearSales - PreviousYearSales) / PreviousYearSales, BLANK())


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Thank you .
I especially like the additional text and explanations it is very helpful

Angith_Nair
Continued Contributor
Continued Contributor

Hi @LUCASM 

Try to create multiple measures as shown below.

Measure for Previous Year's Value:

Value LY = 
CALCULATE(
    SUM(Forecast[Sales]),
    FILTER(
        ALL(Forecast),
        Forecast[Year] = MAX(Forecast[Year]) - 1
    )
)

Measure for YoY Difference:

YoY Difference = 
SUM(Forecast[Sales]) - [Value LY]

Measure for YoY Difference Percentage:

YoY Difference % = 
DIVIDE([YoY Difference], [Value LY], 0)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.