Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2007

Tip: Looking for answers? Try searching our database.

How does this formula work?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Heaton - 08 Nov 2007 01:58 GMT
I have a list of numbers in rows D7:D28, and another list of numbers in
E7:E28

I then add this formula to rows G14:G24 (the placement is actually
irrelevant)

{=AVERAGE(IF(D$7:D$28=D14,E$7:E$28,""))}          (please note its an array
formula)

can someone explain how this formula works and hence relates to the two
lists

thanks
T. Valko - 08 Nov 2007 06:11 GMT
Let's use a smaller set of ranges to see how this works.

..........D..........E
1.......10.........10
2.......12.........15
3.......10.........20
4.......17.........20
5.......10.........30

=AVERAGE(IF(D$1:D$5=D3,E$1:E$5))

The IF function takes 3 arguments, a logical_test, a value_if_ true and a
value_if_ false. In the above formula the logical test is D$1:D$5=D3, the
value_if_true is E$1:E$5 and the value_if_false has been ommited so it
*defaults* to FALSE.

The logical_test will evaluate to an array of either TRUE or FALSE. Like
this:

D1 = D3 = TRUE
D2 = D3 = FALSE
D3 = D3 = TRUE
D4 = D3 = FALSE
D5 = D3 = TRUE

So, with the logical_test the corresponding value_if_true or the
value_if_false is then passed to the AVERAGE function and we get the average
of those values.. The value_if_true are the values in the range E1:E5 and
the value_if_false is the default FALSE. That would look like this: (T=TRUE,
F=FALSE)

D1 = D3 = T = E1 = 10
D2 = D3 = F = F   = F
D3 = D3 = T = E3 = 20
D4 = D3 = F = F   = F
D5 = D3 = T = E5 = 30

So, at this point the average function looks like this:

=AVERAGE({10,FALSE,20,FALSE,30}) = 20

AVERAGE ignores logical values (TRUE,FALSE) and text values that are
*elements of an array* so we get the average of 10, 20, and 30.

The formula you posted uses an empty TEXT string as the value_if_false
argument:

=AVERAGE(IF(D$7:D$28=D14,E$7:E$28,""))

So, this is what the average function would look like (based on the ranges
I've used in this example):

=AVERAGE({10,"",20,"",30}) = 20

Signature

Biff
Microsoft Excel MVP

>I have a list of numbers in rows D7:D28, and another list of numbers in
>E7:E28
[quoted text clipped - 9 lines]
>
> thanks
David Heaton - 08 Nov 2007 08:27 GMT
thanks very much the explanation was great.

I really didnt fully understand how array formulas worked and this has
helped a lot.

Thanks again

David

> Let's use a smaller set of ranges to see how this works.
>
[quoted text clipped - 63 lines]
>>
>> thanks
TheHeatons - 08 Nov 2007 08:43 GMT
> Let's use a smaller set of ranges to see how this works.
>
[quoted text clipped - 69 lines]
>
> - Show quoted text -

thanks very much the explanation was great.

I really didnt fully understand how array formulas worked and this
has
helped a lot.

Thanks again

David
T. Valko - 08 Nov 2007 17:21 GMT
>> Let's use a smaller set of ranges to see how this works.
>>
[quoted text clipped - 82 lines]
>
> David

You're welcome. Thanks for the feedback!

Signature

Biff
Microsoft Excel MVP

ilia - 08 Nov 2007 19:32 GMT
A good way to figure these out is to use the Tools -> Formula Auditing
-> Evaluate.  This will, usually, list all the intermediate array
results.

> > Let's use a smaller set of ranges to see how this works.
>
[quoted text clipped - 85 lines]
>
> - Show quoted text -
TheHeatons - 08 Nov 2007 22:48 GMT
> A good way to figure these out is to use the Tools -> Formula Auditing
> -> Evaluate.  This will, usually, list all the intermediate array
[quoted text clipped - 91 lines]
>
> - Show quoted text

Fantastic...thats something else I wasnt aware of....thanks a lot
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.