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

Summing two years as a single year

Hi, I have a pretty complex issue that I am working on and I am wondering if PowerBI has the capability to do this.

I am calculating energy savings from energy conservation projects, where I need to sum the one column from this year, and another column from last year. For example, the total 2020 savings would be (column A total in 2019) plus (column B total in 2020).

Every attempt I have made has resulted in (A in 2019 + B in 2019) and (A in 2020 + B in 2020) when I try to add the year field to my chart.

I have a large calendar table which has year offsets etc but I can't figure out a way to make use of that for this task.

If anybody has some ideas I could try that would be amazing.

thanks

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

Hi, @Anonymous ;

You could create a measure such as:

Measure = CALCULATE(SUM([A]),FILTER('Table',YEAR([Date])=2019))+CALCULATE(SUM([B]),FILTER('Table',YEAR([Date])=2020))

The final output is shown below:

vyalanwumsft_0-1642138612215.png

If the problem is still not resolved, please provide  the expected result you expect. Let me know immediately, looking forward to your reply.


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a measure such as:

Measure = CALCULATE(SUM([A]),FILTER('Table',YEAR([Date])=2019))+CALCULATE(SUM([B]),FILTER('Table',YEAR([Date])=2020))

The final output is shown below:

vyalanwumsft_0-1642138612215.png

If the problem is still not resolved, please provide  the expected result you expect. Let me know immediately, looking forward to your reply.


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , sum of two columns in not a problem 

 

You can select a five year range on page or can control year in measure 

 

Assume date in the table is joined with data of date and no date filter on page 

 

measure =

var _max = year(maxx(allselected('Date'), 'Date'[Date]))

var _min =_max -5

return

calculate(sum(Table[A]) + sum(Table[B]), filter('date', 'date'[Year] >=_min && 'Date'[Year] <=_max) )

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.