View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
[email protected] paul.robinson@it-tallaght.ie is offline
external usenet poster
 
Posts: 789
Default {=AVERAGE(AND(B6:B15=B3,B6:B15<B4),C6:C15)}

Hi
AND(B6:B15=B3,B6:B15<B4) can evaluate to 1 or 0.
AND(B6:B15=B3,B6:B15<B4),C6:C15 is now 11 numbers (a 1 or 0 and 10
10's)
Your array formula, I think, will return the AND condition on the last
row (which is 0) averaged with the ten numbers. This average is 100/11
= 9.09090909...

Try
{=SUM(IF(B6:B15<B4,1,0)*IF(B6:B15=B3,1,0)*C6:C15)/SUM(IF(B6:B15<B4,1,0)*IF(B6:B15=B3,1,0))}

The top sum adds the tens meeting both criteria, which is 30. The
bottom sum counts the number of entries meeting the criteria, which is
3. So the average is 10.
Note that
{=AVERAGE(IF(B6:B15<B4,1,0)*IF(B6:B15=B3,1,0)*C6: C15)}

will give 3, as the sum part will be 30, but you will have 10 numbers
in the range.

regards
Paul

deano wrote:

11/01/06 10.0
11/02/06 10.0
11/03/06 10.0
11/04/06 10.0
11/05/06 10.0
11/06/06 10.0
11/07/06 10.0
11/08/06 10.0
11/09/06 10.0
11/10/06 10.0

the above range is placed in B6:B15

cell B3 contains 11/01/06
cell B4 contains 11/05/06

doing a simple average(C6:C9) produces 10
placing a conditional average if cells B6:B15 are between 11/01/06 and
11/05/06 , average corresponding cells in C6:C15 as in expression

{=AVERAGE(AND(B6:B15=B3,B6:B15<B4),C6:C15)} produces an incorrect
result = 9.09

why is that ?

cheers,
deano