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

Get Fabric certified for FREE! Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Calculate Variance of Sum By Row Criteria Over Previous Year

Hi guys, not quite sure how to word this the best, but I am trying to create a measure that will allow me to display the variance for any of the accounts, over the previous year.  For example what would be the variance in year 2017 for account 1, from year 2016, etc.

Here is some sample data:

 

2015Act 1$10
2015Act 2$31
2016Act 1$21
2016Act 2$21
2017Act 1$12

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

You can use this measure

variance = 
VAR _year = MAX(SampleTable[Year])
VAR _thisYear = SUM(SampleTable[Price])
VAR _previousYear = CALCULATE(SUM(SampleTable[Price]),ALLEXCEPT(SampleTable,SampleTable[Account]),SampleTable[Year] = _year - 1)
RETURN
_thisYear - _previousYear

vjingzhang_0-1654744094239.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

You can use this measure

variance = 
VAR _year = MAX(SampleTable[Year])
VAR _thisYear = SUM(SampleTable[Price])
VAR _previousYear = CALCULATE(SUM(SampleTable[Price]),ALLEXCEPT(SampleTable,SampleTable[Account]),SampleTable[Year] = _year - 1)
RETURN
_thisYear - _previousYear

vjingzhang_0-1654744094239.png

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.