ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   average-if-and formula (https://www.excelbanter.com/excel-worksheet-functions/165875-average-if-formula.html)

Knox

average-if-and formula
 
{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N1324 1,""))}

why doesn't this formula work? thanx!

Mike H

average-if-and formula
 
one way

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


Mike

"Knox" wrote:

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

why doesn't this formula work? thanx!


Don Guillett

average-if-and formula
 
Use this. Array enter.
=AVERAGE(IF((B2:B22=1)*(D2:D22=2),N2:N22))

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Knox" wrote in message
...
{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N1324 1,""))}

why doesn't this formula work? thanx!



Stephen[_2_]

average-if-and formula
 
"Knox" wrote in message
...
{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N1324 1,""))}

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,""))}



Max

average-if-and formula
 
"Knox" wrote:
{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N1324 1,""))}


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
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---


Knox

average-if-and formula
 
Thank you all!

"Stephen" wrote:

"Knox" wrote in message
...
{=AVERAGE(IF(AND(B2:B13241=1,D2:D13241=2),N2:N1324 1,""))}

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,""))}





All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com