average-if-and formula

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N13241,""))}

why doesn't this formula work? thanx!
 
one way

=SUMPRODUCT((B2:B13241=1)*(D2:D13241=2)*(N2:N13241))/SUMPRODUCT((B2:B13241=1)*(D2:D13241=2)*(N2:N13241<>0))


Mike
 
Knox said:
{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N13241,""))}

why doesn't this formula work? thanx!

Because you can't use AND with arrays (as it returns only a single result,
not an array). Instead you need to multiply the two arrays:
{=AVERAGE(IF((B2:B13=1)*(D2:D13=2),N2:N13,""))}
 
Knox said:
{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N13241,""))}

You could also try it slightly amended like this, array-entered with CSE*:
=AVERAGE(IF((B2:B13241=1)*(D2:D13241=2),N2:N13241))

*CSE = Press CTRL+SHIFT+ENTER to confirm the formula

---
 
Thank you all!

Stephen said:
Because you can't use AND with arrays (as it returns only a single result,
not an array). Instead you need to multiply the two arrays:
{=AVERAGE(IF((B2:B13=1)*(D2:D13=2),N2:N13,""))}
 
Back
Top