Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Average If year in excel 2007

Posted on 2011-02-14
6
Medium Priority
?
1,073 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 50

Accepted Solution

by:
barry houdini earned 2000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 50

Assisted Solution

by:barry houdini
barry houdini earned 2000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
One-stop solution for Exchange Administrators to address all MS Exchange Server issues, which is known by the name of Stellar Exchange Toolkit.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

730 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