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

Help to calculate the difference between two years

Hi,
 
Would really appreciate any help. I'm still learning Power BI and struggling to create a card which shows the difference in the average % from 2020 and 2015.
 
I've tried a couple methods including one with a single formula and the other with several measures from another solution posted. Unfortunately I couldn't get both to work.
1. Measures:
2014 Average = CALCULATE(AVERAGE('Strategic Projects'[Local Content (%)]),'Calendar'[Date]="2014")
2020 Average = CALCULATE(AVERAGE('Strategic Projects'[Local Content (%)]),'Calendar'[Date]="2020")
2020 to 2014 difference = [2020 Average]-[2014 Average]

2. Other method tried:
Difference 2020 to 2015 = [Local Content Average],YEAR([Date signed or approved]=2020) - [Local Content Average],YEAR([Date signed or approved]=2015)
 
Would you have some suggestions on how I can fix my approach to this?


Thanks!
Brendan
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , In case you have selected a year or something from calendar table , then prefer to use all in calendar filter

 

2014 Average = CALCULATE(AVERAGE('Strategic Projects'[Local Content (%)]),filter(all('Calendar'),'Calendar'[Date]="2014"))


2020 Average = CALCULATE(AVERAGE('Strategic Projects'[Local Content (%)]),filter(all('Calendar'),'Calendar'[Date]="2014"))


2020 to 2014 difference = [2020 Average]-[2014 Average]

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi  @Anonymous  ,

According to your description, data was created from 2014 to 2020:

v-yangliu-msft_0-1608540690098.png

Here are the steps you can follow:

1. Create calaculated column.

Year = YEAR('Table'[Date])

2. Create measure.

avg_year =
var _firstyear=MIN('Table'[Year])
var _lastyear=MAX('Table'[Year])
return
CALCULATE(AVERAGE('Table'[amount]),ALLEXCEPT('Table','Table'[Year]),FILTER('Table','Table'[Year]=_firstyear))
-
CALCULATE(AVERAGE('Table'[amount]),ALLEXCEPT('Table','Table'[Year]),FILTER('Table','Table'[Year]=_lastyear))

3. Result

Put the year field in the slicer, and set the AVG_ Year is put into the card, two years are selected in the slicer, and the average value of these two years is shown in the card

v-yangliu-msft_1-1608540690109.png

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

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 , In case you have selected a year or something from calendar table , then prefer to use all in calendar filter

 

2014 Average = CALCULATE(AVERAGE('Strategic Projects'[Local Content (%)]),filter(all('Calendar'),'Calendar'[Date]="2014"))


2020 Average = CALCULATE(AVERAGE('Strategic Projects'[Local Content (%)]),filter(all('Calendar'),'Calendar'[Date]="2014"))


2020 to 2014 difference = [2020 Average]-[2014 Average]

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.