ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   what is wrong with this formula (https://www.excelbanter.com/excel-programming/439968-what-wrong-formula.html)

Norbert[_2_]

what is wrong with this formula
 
=SUMPRODUCT((A1:A21=D1)*(B1:B21),(F1:F7))/SUMPRODUCT(--(A1:A21=D1),--(B1:B21))

results in #VALUE!

#WHY?



Joe User[_2_]

what is wrong with this formula
 
"Norbert" wrote:
=SUMPRODUCT((A1:A21=D1)*(B1:B21),(F1:F7))
/SUMPRODUCT(--(A1:A21=D1),--(B1:B21))
results in #VALUE! #WHY?


One reason: because the ranges A1:A21, B1:B21 and F1:F7 are not all the
same size.

Another possible reason: If "F1:F7" is a typo and you mean F1:F21, because
some cells in B1:B21 contain text, not numbers or boolean values (true,
false).

If B1:B21 contains boolean values (true, false), then the formula can be
rewritten as follows:

=SUMPRODUCT(--(A1:A21=D1),--B1:B21,F1:F21)
/SUMPRODUCT(--(A1:A21=D1),--B1:B21)

If you want to consider only numeric values in B1:B21, then use one of the
following formulas(equivalent):

=SUMPRODUCT(--(A1:A21=D1),B1:B21,F1:F21)
/SUMPRODUCT(--(A1:A21=D1),B1:B21)

or

=SUMPRODUCT(--(A1:A21=D1),B1:B21,F1:F21)
/SUMIF(A1:A21,D1,B1:B21)

The double negation ("--") is needed only to convert boolean values (true,
false) to numbers (1, 0).



All times are GMT +1. The time now is 01:52 AM.

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