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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
SecretChimpanze
Frequent Visitor

Year on year variance - calculated measure

Hi,

 

How would I be able to calculate the year on year variance of two lines on a chart? The plan is to show the variance in a separate line chart.

 

What I currently have is:

X Axis = Launch Week +/- (this is from my date table and Week 0 is launch week. I have around 3 months worth of weeks showing)

Legend = Financial Year (2021 and 2022) also from my date table

Value = Count of Events (from my data table)

 

What I need is to have a calculated measure that does this --> 2022 data minus 2021 data for whichever week I have showing on my X Axis (this can change depending on the dates selected in a slicer)

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@SecretChimpanze Try:

 

 

Better Year Over Year Change = 
    VAR __Year = MAX('Table'[Year])
    VAR __Curr = SUMX(FILTER(ALL('Table'),[Year] = __Year),[Value])
    VAR __Prev = SUMX(FILTER(ALL('Table'),[Year] = __Year - 1),[Value])
RETURN
    DIVIDE(__Curr - __Prev, __Prev, 0)

 

or possibly:

 

Better Year Over Year Change 2 = 
    VAR __Year = MAX('Table'[Year])
    VAR __EndDate = MAX('Table'[Date])
    VAR __StartDate = MIN('Table'[Date])
    VAR __PrevDateEnd = DATE(YEAR(__EndDate) - 1, MONTH(__EndDate), DAY(__EndDate))
    VAR __PrevDateStart = DATE(YEAR(__StartDate) - 1, MONTH(__StartDate), DAY(__StartDate))
    VAR __Curr = SUMX(FILTER(ALL('Table'),[Date] <= __EndDate && [Date] >= __StartDate),[Value])
    VAR __Prev = SUMX(FILTER(ALL('Table'),[Date] <= __PrevDateEnd && [Date] >= __PrevDateStart),[Value])
RETURN
    DIVIDE(__Curr - __Prev, __Prev, 0)

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@SecretChimpanze Try:

 

 

Better Year Over Year Change = 
    VAR __Year = MAX('Table'[Year])
    VAR __Curr = SUMX(FILTER(ALL('Table'),[Year] = __Year),[Value])
    VAR __Prev = SUMX(FILTER(ALL('Table'),[Year] = __Year - 1),[Value])
RETURN
    DIVIDE(__Curr - __Prev, __Prev, 0)

 

or possibly:

 

Better Year Over Year Change 2 = 
    VAR __Year = MAX('Table'[Year])
    VAR __EndDate = MAX('Table'[Date])
    VAR __StartDate = MIN('Table'[Date])
    VAR __PrevDateEnd = DATE(YEAR(__EndDate) - 1, MONTH(__EndDate), DAY(__EndDate))
    VAR __PrevDateStart = DATE(YEAR(__StartDate) - 1, MONTH(__StartDate), DAY(__StartDate))
    VAR __Curr = SUMX(FILTER(ALL('Table'),[Date] <= __EndDate && [Date] >= __StartDate),[Value])
    VAR __Prev = SUMX(FILTER(ALL('Table'),[Date] <= __PrevDateEnd && [Date] >= __PrevDateStart),[Value])
RETURN
    DIVIDE(__Curr - __Prev, __Prev, 0)

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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