Average calculations w/validation cell

K

Kgov

I am using a validation cell to allow the user to pick if they want the
average to be calculated based on 2,3 or 4 years. I'm trying to develop a
formula so that after the # of years is picked it will then add 2, 3 or 4
other cells and give the appropriate averge...
 
K

Kgov

Thanks for the advice Bernard.

A bit more information....

A B C
1 2005 20 15
2 2006 12 18
3 2007 22 45
4 2008 16 19


6 2 3 Validation cell. # of years
adds last 2, 3 yrs etc.
7 19* 27* always starting with 2008 CY


*16+22=38/2=19
*19+45+18=82/3=27
 
B

Bernard Liengme

In cell B7 under the 2 use one of these and copy to B7
a)
=SUMPRODUCT(--($A$1:$A$4>$A$4-B6),B1:B4)/SUMPRODUCT(--($A$1:$A$4>$A$4-B6))
b) =SUMIF($A$1:$A$4,">"&$A$4-B6,B1:B4)/COUNTIF($A$1:$A$4,">"&$A$4-B6)
c) in XL2070 only
=AVERAGEIF($A$1:$A$4,">"&$A$4-B6,B1:B4)
best wishes
 
B

Bernard Liengme

A phrase like (A1:A4>4) returns an array of Boolean values such as {FALSE,
TRUE, TRUE, TRUE}
When you perform an arithmetic operation on a Boolean, Excel treated TRUE as
1 and FALSE as zero
A convenient thing to do is to double negate the values (change the sign and
then change it again) - which means they stay the same but become numbers
So --(A1:A4>4) would then give us {0,1,1,1}

J.E McGimpsey is tell all at:
http://mcgimpsey.com/excel/formulae/doubleneg.html

best wishes
 

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