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
Anonymous
Not applicable

Calculate Year over Year Variance, Earlier Function Not Working

I've literally spent hours trying to figure this out. I've looked at the following posts:

 

Calculating-Variance-Year-on-Year

How-to-subtract-current-row-from-prior-row-and-so-on-in-power-bi

calculate-variance-in-powerbi-using-dax-query

 

I've tried countless of variations of the three links above without success. I'm trying to create a year over year variance of the following table:

 

image.png

 

The following are the expected results:

 

image.png

 

Thanks in advance for helping me.

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

Hi @Anonymous

"Earlier Function" can only be used in the calculated column, when you create a measure, you need to use "MAX" function instead.

calculated columns

variance1 =
VAR earliervalue =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = EARLIER ( Table1[year] ) - 1 )
    )
RETURN
    IF ( earliervalue <> BLANK (), [pricipal balance] - earliervalue )

variance1% =
VAR earliervalue =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = EARLIER ( Table1[year] ) - 1 )
    )
RETURN
    [variance1] / earliervalue

5.png

 

Measures

variance2 =
VAR earliervalue2 =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = MAX ( Table1[year] ) - 1 )
    )
RETURN
    IF ( earliervalue2 <> BLANK (), MAX ( [pricipal balance] ) - earliervalue2 )

variance2% =
VAR earliervalue2 =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = MAX ( Table1[year] ) - 1 )
    )
RETURN
    [variance2] / earliervalue2

6.png

 

Best Reagrds

Maggie

View solution in original post

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

"Earlier Function" can only be used in the calculated column, when you create a measure, you need to use "MAX" function instead.

calculated columns

variance1 =
VAR earliervalue =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = EARLIER ( Table1[year] ) - 1 )
    )
RETURN
    IF ( earliervalue <> BLANK (), [pricipal balance] - earliervalue )

variance1% =
VAR earliervalue =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = EARLIER ( Table1[year] ) - 1 )
    )
RETURN
    [variance1] / earliervalue

5.png

 

Measures

variance2 =
VAR earliervalue2 =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = MAX ( Table1[year] ) - 1 )
    )
RETURN
    IF ( earliervalue2 <> BLANK (), MAX ( [pricipal balance] ) - earliervalue2 )

variance2% =
VAR earliervalue2 =
    CALCULATE (
        SUM ( Table1[pricipal balance] ),
        FILTER ( ALL ( Table1 ), [year] = MAX ( Table1[year] ) - 1 )
    )
RETURN
    [variance2] / earliervalue2

6.png

 

Best Reagrds

Maggie

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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