COUNT ONLY CELLS THAT AREN'T BLANK

P

paulinec

This is the present function I have to get an average of $D$4:$D$3710:
=(SUMIF($A$4:$A$3710,A3742,$D$4:$D$3710))/(COUNTIF($A$4:$A$3710,A3742)
The problem with this is that it is counting all cells in $A$4:$A$3710 that
equal A3742.
To get a correct average I need to only count cells that are not blank in
$D$4:$D$3710 based on $A$4:$A$3710 equalling A3742.
Can anyone help me with this?
 
D

Dave R.

change that /(countif part to:

SUMPRODUCT(($A$4:$A$3710=A3742)*($D$4:$D$3710<>""))
 
H

hrlngrv

paulinec wrote...
This is the present function I have to get an average of $D$4:$D$3710:
=(SUMIF($A$4:$A$3710,A3742,$D$4:$D$3710))/(COUNTIF($A$4:$A$3710,A3742)
The problem with this is that it is counting all cells in $A$4:$A$3710 that
equal A3742.
To get a correct average I need to only count cells that are not blank in
$D$4:$D$3710 based on $A$4:$A$3710 equalling A3742.
....

You may be better off using the array formula

=AVERAGE(IF($A$4:$A$3710=A3742,$D$4:$D$3710))

which will skip nonnumeric cells in D4:D3710. If you can't use array
formulas, then you need to use a 2-criteria denominator.

=SUMIF($A$4:$A$3710,A3742,$D$4:$D$3710)
/SUMPRODUCT(--($A$4:$A$3710=A3742),--ISNUMBER($D$4:$D$3710))
 
W

William

Hi Pauline

I'm not sure I completely understand your question, but to return an average
of cells D4:D3710 that are not blank use this array formula which you should
enter by pressing Ctrl|Shift|Enter at the same time rather than just "Enter"

{=AVERAGE(IF(D4:D3710<>"",D4:D3710))}

I dont see the relevance of cell A3742 - if you want an average of those
cells that equal cell A3742, then cell A3742 would be the average - what am
I missing?

--
XL2002
Regards

William

(e-mail address removed)

| This is the present function I have to get an average of $D$4:$D$3710:
| =(SUMIF($A$4:$A$3710,A3742,$D$4:$D$3710))/(COUNTIF($A$4:$A$3710,A3742)
| The problem with this is that it is counting all cells in $A$4:$A$3710
that
| equal A3742.
| To get a correct average I need to only count cells that are not blank in
| $D$4:$D$3710 based on $A$4:$A$3710 equalling A3742.
| Can anyone help me with this?
| --
| PaulineC
 
W

William

Bad day - ignore the last part of my post :-(

--
XL2002
Regards

William

(e-mail address removed)

| Hi Pauline
|
| I'm not sure I completely understand your question, but to return an
average
| of cells D4:D3710 that are not blank use this array formula which you
should
| enter by pressing Ctrl|Shift|Enter at the same time rather than just
"Enter"
|
| {=AVERAGE(IF(D4:D3710<>"",D4:D3710))}
|
| I dont see the relevance of cell A3742 - if you want an average of those
| cells that equal cell A3742, then cell A3742 would be the average - what
am
| I missing?
|
| --
| XL2002
| Regards
|
| William
|
| (e-mail address removed)
|
| | | This is the present function I have to get an average of $D$4:$D$3710:
| | =(SUMIF($A$4:$A$3710,A3742,$D$4:$D$3710))/(COUNTIF($A$4:$A$3710,A3742)
| | The problem with this is that it is counting all cells in $A$4:$A$3710
| that
| | equal A3742.
| | To get a correct average I need to only count cells that are not blank
in
| | $D$4:$D$3710 based on $A$4:$A$3710 equalling A3742.
| | Can anyone help me with this?
| | --
| | PaulineC
|
|
|
 
P

paulinec

To explain a bit further Row A1:3710 contains a farm number, Row B1:B3710
contains paddock nos, Row D1:D3710 contains a row length for each paddock. As
some paddocks are not planted there are some blank cells in the row length
column.

In row 4742 I am trying to get an average row lengh for each farm. To be
accurate it has to be an average of the cells that contain row lengths.

At present it is averaging on the total number of paddocks in each farm.
 
W

William

Hi Pauline
Try...
=AVERAGE(IF(D4:D3710<>"",IF(A4:A3710=F4742,D4:D3710)))
where the farm number you are trying to average is in cell F4742

--
XL2002
Regards

William

(e-mail address removed)

| To explain a bit further Row A1:3710 contains a farm number, Row B1:B3710
| contains paddock nos, Row D1:D3710 contains a row length for each paddock.
As
| some paddocks are not planted there are some blank cells in the row length
| column.
|
| In row 4742 I am trying to get an average row lengh for each farm. To be
| accurate it has to be an average of the cells that contain row lengths.
|
| At present it is averaging on the total number of paddocks in each farm.
|
| "William" wrote:
|
| > Bad day - ignore the last part of my post :-(
| >
| > --
| > XL2002
| > Regards
| >
| > William
| >
| > (e-mail address removed)
| >
| > | > | Hi Pauline
| > |
| > | I'm not sure I completely understand your question, but to return an
| > average
| > | of cells D4:D3710 that are not blank use this array formula which you
| > should
| > | enter by pressing Ctrl|Shift|Enter at the same time rather than just
| > "Enter"
| > |
| > | {=AVERAGE(IF(D4:D3710<>"",D4:D3710))}
| > |
| > | I dont see the relevance of cell A3742 - if you want an average of
those
| > | cells that equal cell A3742, then cell A3742 would be the average -
what
| > am
| > | I missing?
| > |
| > | --
| > | XL2002
| > | Regards
| > |
| > | William
| > |
| > | (e-mail address removed)
| > |
| > | | > | | This is the present function I have to get an average of
$D$4:$D$3710:
| > | |
=(SUMIF($A$4:$A$3710,A3742,$D$4:$D$3710))/(COUNTIF($A$4:$A$3710,A3742)
| > | | The problem with this is that it is counting all cells in
$A$4:$A$3710
| > | that
| > | | equal A3742.
| > | | To get a correct average I need to only count cells that are not
blank
| > in
| > | | $D$4:$D$3710 based on $A$4:$A$3710 equalling A3742.
| > | | Can anyone help me with this?
| > | | --
| > | | PaulineC
| > |
| > |
| > |
| >
| >
| >
 
P

paulinec

Yes, that worked, thank you so much for that. Just one more question. What
is the reason for the two -- in the formula?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top