Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

averageifs

ResolvedVersion 2010

Andrew has attended:
Excel Advanced course
Excel VBA Intro Intermediate course
Excel Advanced - For Power Users course
Excel Dashboards for Business Intelligence course

AVERAGEIFS

Hi,

Can you help me with the following please?

The formula immediately below works perfectly well and gives me the average length of service based on values in Column O, with employees in Cost Code (YA00).

=AVERAGEIFS('Report - Headcount'!$O:$O,'Report - Headcount'!$A:$A,"YA00",'Report - Headcount'!$J:$J,"*Regular")

I'm trying to add a second criteria (Cost Code) so it looks at PA00 as well but without success. Can you see what's wrong with my formula? Should I be using an OR statement? If yes then how do I incorporate it into the formula?

=AVERAGEIFS('Report - Headcount'!$O:$O,'Report - Headcount'!$A:$A,"YA00",'Report - Headcount'!$J:$J,"*Regular",'Report - Headcount'!$A:$A,"PA00",'Report - Headcount'!$J:$J,"*Regular")

RE: AVERAGEIFS

Hi Andrew,

Thank you for your post. The Averageif function tends to break sometimes when you use the same criteria range more than once. One possible solution is shown below. I've tested it and it works on my sheet.

=AVERAGE(AVERAGEIFS('Report - Headcount'!$O:$O,'Report - Headcount'!$A:$A,"YA00",'Report - Headcount'!$J:$J,"*Regular"),AVERAGEIFS('Report - Headcount'!$A:$A,"PA00",'Report - Headcount'!$J:$J,"*Regular")).

I hope this helps

Kind regards
Marius Barnard
Excel Trainer

RE: AVERAGEIFS

Hi Marcus,

I've run the formula within the same worksheet this time so it's easier to read. It still doesn't work as it says I've entered too few arguments for this function. This is the updated formula with your suggestion incorporated into it:
=AVERAGE(AVERAGEIFS($O:$O,A:A,"YA00",$J:$J,"*Regular"),AVERAGEIFS($A:$A,"PA00",$J:$J,"*Regular"))

RE: AVERAGEIFS

Hi Andrew,

I notice that in your formula, the first instance of A:A needs to read $A:$A.

This will probably solve it.

Kind regards
Marius

RE: AVERAGEIFS

It still says too few arguments.

=AVERAGE(AVERAGEIFS($O:$O,$A:$A,"YA00",$J:$J,"*Regular"),AVERAGEIFS($A:$A,"PA00",$J:$J,"*Regular"))

Here is a sample of what is contained in each of the 3 columns.

Col O = Length of service in years e.g. 4.6
Col A = PA00, YA00 and many others
Col J = Full-Time Regular etc

As I'm trying to find the average length of service in both YA and PA, should I be using a sumif and countif combination? If so, how would the formula look?

RE: AVERAGEIFS

Hi Andrew,

Looking at your formula again, I also notice that in the second Averageifs, it's lacking the $O:$O before the $A:$A. This, of course, is the column containing the values. Sorry, I didn't spot this earlier.

Kind regards
Marius

RE: AVERAGEIFS

Yes, I just spotted that as well and it works now.

Thanks for all of your help on this Marcus - much appreciated!

Andrew

Excel tip:

Change the default location for opening and saving spreadsheets

If you are always opening spreadsheets from and/or saving documents to a specific location that is not My Documents, save time by setting this folder as the default for opening files from and saving files to.

Here's how:
1. Go to Tools - Options.

2. Select the General tab.

3. Enter the pathname of the folder you wish to make the default in the Default File Location box (hint: it will be easier to use Windows Explorer to navigate to this folder, then copy and paste the pathname from the address bar at the top of the Windows Explorer screen).

4. Click OK.

You have now changed the default folder for opening and saving spreadsheets.

View all Excel hints and tips

Connect with us:

0207 987 3777

Call for assistance

Request Callback

We will call you back

Server loaded in 0.1 secs.