Solved

Average If year in excel 2007

Posted on 2011-02-14
6
972 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 50

Assisted Solution

by:barry houdini
barry houdini earned 500 total points
Comment Utility
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
Comment Utility
...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
Comment Utility
barryhoudini, thank you so much!

Both your suggestions worked like a charm!
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A list of useful business intelligence software.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now