Forum Discussion
Sum multiple values based on matches
PeterBartholomew1 , why not SUMPRODUCT()?
It would do fine and work with older versions of Excel. Mind you, I remember first seeing a formula of the form
= SUMPRODUCT(
--(fieldA=fieldH),
--(fieldB=fieldI),
valueField
)and being utterly confused! At first, I couldn't see where multiplication entered the story and the "--" did not achieve anything obvious (a somewhat arcane special notation perhaps). One gets to take it for granted, even its 'magic' array wrapper property!
- SergeiBaklanJul 26, 2022Diamond Contributor
PeterBartholomew1 , don't know why, but I always use it with multiplication
=SUMPRODUCT( (fieldA=fieldH) * (fieldB=fieldI) * valueField )Long ago I knew the difference between these forms, it is in some cases. Bit lazy to dig now where it is.
- HansVogelaarJul 26, 2022MVP
Multiplication is required if the ranges don't have the same size. For example, if valueField is a multi-row and multi-column range, fieldA is a single column and fieldB is a single row.
- SergeiBaklanJul 26, 2022Diamond Contributor
HansVogelaar , thank you