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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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