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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.