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
gsmith_eqd
Frequent Visitor

Calculated column to compare aggregated value from a different row

I have aggregated the monthly sales from my salesorder table to a table containing the monthly sales information. What I'm trying to do is create a column that references the monthly sales from the previous year to show the monthly change.

 

This is a model of what I have so far:

 

MonthYearThisMonthSales
January2018$1000
January2019$2000
January 2020$3000
January 2021$4000
February2019$1500
February2020$2500

 

This is what I'd like to create:

 

MonthYearThisMonthSalesLastYearMonthSales
January2018$1000 
January2019$2000$1000
January 2020$3000$2000
January 2021$4000$3000
February2019$1500 
February2020$2500

$1500

 

I tried this command, but the issue I'm running into is that the calculated column contains the yearly aggregated sales instead of the monthly sales:

 

Column =
VAR Last_Year = 'Table'[Year] - 1
RETURN
CALCULATE(SUM('Table'[This Month Sales]), ALL('Table'), 'Table'[Year] = Last_Year, 'Table'[Month] = 'Table'[Month])

 

What's the best way for me to accomplish this?

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

@gsmith_eqd 
please try

Column =
VAR Last_Year = 'Table'[Year] - 1
RETURN
CALCULATE (
SUM ( 'Table'[This Month Sales] ),
ALLEXCEPT ( 'Table', 'Table'[Month] ),
'Table'[Year] = Last_Year
)

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

@gsmith_eqd 
please try

Column =
VAR Last_Year = 'Table'[Year] - 1
RETURN
CALCULATE (
SUM ( 'Table'[This Month Sales] ),
ALLEXCEPT ( 'Table', 'Table'[Month] ),
'Table'[Year] = Last_Year
)

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.