Averaging, but excluding zeros

T

Tami

i have weekly inventory in a spreadsheet....but the columns are not right
next to eachother...for example columns a, c, e, and g have
inventory.....Sales may be in column b,d,f and h. I need a formula in column
z that averages a,c,e and g. But if the inventory is zero, don't average it.
 
T

Teethless mama

=AVERAGE(IF((A2:G7<>0)*(MOD(COLUMN(A2:G7),2)=1),A2:G7))

ctrl+shift+enter, not just enter

Adjust your range to suit
 
H

Harlan Grove

Tami said:
i have weekly inventory in a spreadsheet....but the columns are not right
next to eachother...for example columns a, c, e, and g have
inventory.....Sales may be in column b,d,f and h.  I need a formula in column
z that averages a,c,e and g. But if the inventory is zero, don't average it.

If you had 0 for inventory in columns A, C and G but 20 in column E,
do you really want your 'average' to appear as 20 rather than 5? If
the inventory zeros mean there's no inventory in a particular week
when there usually would be positive inventory, then those zeros are
valid numbers and probably should be included in the averages. On the
other hand, if you're using zeros to represent the fact that you don't
carry any inventory for whatever the columns represent (item?
location? something else?) in any week, then it's a mistake to
represent that by 0.

In other words, you may be risking misrepresenting your data if zeros
in columns A, C, E and G represent both no units in stock at
particular times as well as never a particular item in stock in one of
the columns. Better to use 0 to represent occasional/temporary out-of-
stock for items usually kept in stock and blank or a text value for
items never kept in stock. Then you could use AVERAGE to include the
meaningful zeros, and it would automatically skip the blank or text
values.
 
S

Shane Devenshire

Hi,

It is not clear from your question whether you are trying to do this
separately for each row or for the entire columns, here is a similar idea for
a row by row average. Note you can change it to a column average by just
changing G2 to G20 or whatever.

=AVERAGE(IF(A2:G2*(MOD(COLUMN(A2:G2),2)=1)<>0,A2:G2))

this is an array formula so you need to press Shift+Ctrl+Enter

If this helps, please click the Yes button.

Cheers,
Shane Devenshire
 
V

Vicki Lee

Shane Devenshire said:
Hi,

It is not clear from your question whether you are trying to do this
separately for each row or for the entire columns, here is a similar idea for
a row by row average. Note you can change it to a column average by just
changing G2 to G20 or whatever.

=AVERAGE(IF(A2:G2*(MOD(COLUMN(A2:G2),2)=1)<>0,A2:G2))

this is an array formula so you need to press Shift+Ctrl+Enter

If this helps, please click the Yes button.

Cheers,
Shane Devenshire
 

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