Problem Description
In Excel, users can specify condition for an array to just calculate some cells with SUMPRODUCT()
For example,
=SUMPRODUCT(--(A1:A3="John"),(B1:B3),(C1:C3))
or simpler
=SUMPRODUCT((F12:F21=1)*(G12:G21="Z")*H12:H21)
It will only calculate those rows that its A column is John.
Reference
- http://www.sumproduct.com/thought/multiple-criteria
- http://chandoo.org/wp/2009/11/10/excel-sumproduct-formula/
Workaround
- Split it as arguments.
Split complicated syntax as separate arguments and process arguments in custom function method.
The syntax might be:
MYSUMPRODUCT(range1, criteria1, range2, criteria2, ...)
e.g.
MYSUMPRODUCT(A1:A3, "somevalue", B1:B3)
- Turn it to a string
Turn the complicated syntax as a string with double quote like "--(A1:A3=some value)", or simplify syntax to "A1:A3=some value", Then parse it by your own.
- Use another Excel function.
using SUM and SUMIF can achieve the same result as SUMPRODUCT. Please see the example in attached Excel file.
The first 2 workarounds' drawback is they are not compatible with Excel SUMPRODUCT, so users have to convert Excel SUMPRODUCT to your custom one in order to work in ZSS.