ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Three same Formulas (https://www.excelbanter.com/excel-worksheet-functions/215952-three-same-formulas.html)

John[_22_]

Three same Formulas
 
Hi everyone

I've got these three sumproduct formulas that returns the right answer.
=SUMPRODUCT((YEAR(A5:A150)=2008)*(C5:C150="Dept021 ")*B5:B150)
=SUMPRODUCT(--(YEAR(A5:A150)=2008),--(C5:C150="Dept021"),B5:B150)
=SUMPRODUCT(N(YEAR(A5:A150)=2008),N(C5:C150="Dept0 21"),B5:B150)
I would like to know if they're all the same.
Can they be use for different situation.
Any preference over others and for what reason?

Thank you
Regards
John

Bob Phillips[_3_]

Three same Formulas
 
See http://www.xldynamic.com/source/xld.SUMPRODUCT.html

--
__________________________________
HTH

Bob

"John" wrote in message
...
Hi everyone

I've got these three sumproduct formulas that returns the right answer.
=SUMPRODUCT((YEAR(A5:A150)=2008)*(C5:C150="Dept021 ")*B5:B150)
=SUMPRODUCT(--(YEAR(A5:A150)=2008),--(C5:C150="Dept021"),B5:B150)
=SUMPRODUCT(N(YEAR(A5:A150)=2008),N(C5:C150="Dept0 21"),B5:B150)
I would like to know if they're all the same.
Can they be use for different situation.
Any preference over others and for what reason?

Thank you
Regards
John




Spiky

Three same Formulas
 
On Jan 9, 11:32*am, "John" wrote:
Hi everyone

I've got these three sumproduct formulas that returns the right answer.
=SUMPRODUCT((YEAR(A5:A150)=2008)*(C5:C150="Dept021 ")*B5:B150)
=SUMPRODUCT(--(YEAR(A5:A150)=2008),--(C5:C150="Dept021"),B5:B150)
=SUMPRODUCT(N(YEAR(A5:A150)=2008),N(C5:C150="Dept0 21"),B5:B150)
I would like to know if they're all the same.
Can they be use for different situation.
Any preference over others and for what reason?

Thank you
Regards
John


They are all the same. You need to use an operator to get SUMPRODUCT
to see your logical expressions with 1s and 0s instead of TRUEs and
FALSEs. Those formulas all do that in a different way. The most common
seems to be the "--", probably because it is distinctive and
versatile. Pick which you like and always use it so it will be
familiar.


All times are GMT +1. The time now is 02:39 AM.

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