Average If statement ignoring zero's

Adam57

New Member
Joined
Jul 29, 2021
Messages
4
Office Version
  1. 365
  2. 2007
Platform
  1. Windows
Hi all,

I am using a formula within a database i have created. I have now altered the way the data is extracted into the database and this now causes some of the data to return 0's but my formula now looks at these 0's and dilutes my end figures.

Here is the array formula that i am using:

{=AVERAGE(IF($C$6:$C$500=$C503,IF($C$5:$BC$5=D$502-1,$D$6:$BC$500)))}

$C$6:$C$500=$C503 - (In this range, C503 is looking for a particular name[This name can appear more than once])
$C$5:$BC$5=D$502 - (In this range, D502 is looking for a particular number)
$D$6:$BC$500 - (This is the range that houses the data that i need averaging based on the criteria above)

Below is a snip of my sheet, Bob is in cell C6.

The current formula reads, If Adam appears in column C, and the number 4 appears in row 5, then average the data in column D that matches this criteria.
But i now need the same formula to ignore the blank cells/cells that have zero values.

At present the formula will give the outcome of 90 as it will take the 180 next to Adam and also include the blank cell next to the other Adam.

1630709043816.png


A bit long winded but any help on this would be greatly apprecieated.

Thank you

 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Here is the array formula that i am using:

{=AVERAGE(IF($C$6:$C$500=$C503,IF($C$5:$BC$5=D$502-1,$D$6:$BC$500)))}
Are you sure that is the formula you are using, or is it this?
{=AVERAGE(IF($C$6:$C$500=$C503,IF($D$5:$BC$5=D$502-1,$D$6:$BC$500)))}

Try this
{=AVERAGE(IF($C$6:$C$500=$C503,IF($D$5:$BC$5=D$502-1,IF($D$6:$BC$500<>"",$D$6:$BC$500))))}
 
Upvote 0
Are you sure that is the formula you are using, or is it this?
{=AVERAGE(IF($C$6:$C$500=$C503,IF($D$5:$BC$5=D$502-1,$D$6:$BC$500)))}

Try this
{=AVERAGE(IF($C$6:$C$500=$C503,IF($D$5:$BC$5=D$502-1,IF($D$6:$BC$500<>"",$D$6:$BC$500))))}
Hi Peter,

Thank you for your reply,

The formula i pasted is the correct one that i am ising.
If i was to make the changes that you have pointed out then this will return either a #VALUE! as a standard formula, or #DIV/0! as an array.

This is the same for the formula you have pasted, it is returning the same value that i already have unfortunately.
 
Upvote 0
The formula i pasted is the correct one that i am ising.
OK, then I must have guessed incorrectly about what is in D502 and/or the rest of row 5.

What about this then? Your original formula in D505, my adjusted formula in D506.
I have entered these as array formulas with Ctrl+Shift+Enter but I note you have two Excel versions and there would be no need to enter as an array formula if using 365 as shown in D507 which was entered normally (as I am using 365)

21 09 04.xlsm
CDE
5345
6Bob300200
7Adam180200
8Adam
9Dave200100
10
11
12
13
501
5024
503Adam
504
50590
506180
507180
Average
Cell Formulas
RangeFormula
D505D505=AVERAGE(IF($C$6:$C$500=$C503,IF($C$5:$BC$5=D$502-1,$D$6:$BC$500)))
D506D506=AVERAGE(IF($C$6:$C$500=$C503,IF($C$5:$BC$5=D$502-1,IF($D$6:$BC$500<>"",$D$6:$BC$500))))
D507D507=AVERAGE(IF($C$6:$C$500=$C503,IF($C$5:$BC$5=D$502-1,IF($D$6:$BC$500<>"",$D$6:$BC$500))))
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi Peter, The bottom formula seems to have worked. I have changed the <>"" to <>0 and this works fine for me and what i need it for.
Thank you for the perseverance and the help.
Its greatly appreciated.
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,012
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top