cancel
Showing results for 
Search instead for 
Did you mean: 
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]

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

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]

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin

Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Microsoft Ignite 768x460.png

Find your focus

Explore the latest tools,training sessions,technical expertise, networking and more.

Power BI Womens Summit 2021 768 x460.jpg

Interviews, learning sessions, allies, and more!

#PowerBIWomenSummit

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!