Solved

Average If year in excel 2007

Posted on 2011-02-14
6
992 Views
Last Modified: 2013-12-13
Hi,

I'm trying to get the average if the year = 2009 or 2010 etc ...

I tried to use this this formula but it gives me 0 :

=AVERAGE(IF(YEAR(Table3[Date])=2009,Table3[Pricing]))

Open in new window


Please help.


Thank you so much for your time.
0
Comment
Question by:Dido123
6 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 500 total points
ID: 34893302
Hello Dido123,

That formula should work but it's an "array formula" and as such you need to confirm with CTRL+SHIFT+ENTER so that curly braces like { and } apear around the formula in the formula bar.

...or use AVERAGEIFS function

=AVERAGEIFS(Table3[Pricing],Table3[Date],">="&DATE(2009,1,1),Table3[Date],"<"&DATE(2010,1,1))

regards, barry
0
 
LVL 3

Expert Comment

by:OblivionSY
ID: 34893308
I would move the IF statement to the outter clause.

=IF(YEAR(Table3[Date])=2009, AVERAGE(Table3[Pricing]), "Whatever to do if not 2009")

Have not tested that code - but if you supply an excel doc. would be able to have a look in detail.

I am not sure about your YEAR(Table3[Date]) part... would need to see the excel document to commment further
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34893323
I think that the problem with your approach is the cells that are not from 2009 are still included in the AVG calculation.

You may have better luck using a combination of SUMIF and COUNTIF functions instead of AVERAGE.

You'll need to replace date-column-range and pricing-column-range with the proper range expression.

=( SUMIF(date-column-range, 2009, pricing-column-range) / COUNTIF(date-column-range, 2009) )

Open in new window

0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 50

Assisted Solution

by:barry houdini
barry houdini earned 500 total points
ID: 34893334
Hello Oblivion SY,

That won't work I'm afraid - Dido's syntax is OK as I say - it just needs array entering.

sjklein42. The use of YEAR in the formula suggests that the Date field contains a date so you can't use just 2009 in a SUMIF criteria, that won't sum anything.....

See attached for examples of my two suggestions above and a third option which allows you to put the year in a cell I1 and use

=AVERAGEIFS(Table3[Pricing],Table3[Date],">="&DATE(I1,1,1),Table3[Date],"<"&DATE(I1+1,1,1))

regards, barry
26821278.xlsx
0
 
LVL 50

Expert Comment

by:barry houdini
ID: 34893354
...on second thoughts....perhaps you are correct sjklein42, apologies. If there is just a year in the date column then that would be consistent with the formula producing a zero result. If that is the case then you can use sjklein's SUMIF/COUNTIF suggestion or AVERAGEIF like

=AVERAGEIF(Table3[Date],2009,Table3[Pricing])

regards, barry
0
 

Author Closing Comment

by:Dido123
ID: 34893424
barryhoudini, thank you so much!

Both your suggestions worked like a charm!
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Multiple Open Excel Spreadsheets 12 40
remove dups 10 36
ServiceCenter IR Query Expressions 1 18
Merging spreadsheets 8 37
In our personal lives, we have well-designed consumer apps to delight us and make even the most complex transactions simple. Many enterprise applications, however, are a bit behind the times. For an enterprise app to be successful in today's tech wo…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question