For convenience, the D5:D15 isnamedcolor.
TheCOUNTIFS functionwill allow multiple conditions, but all conditions are joined with AND logic.
The article below explains several options.
However,criteriais “red” in the first COUNTIF and “blue” in the second.
The first COUNTIF returns 4 and the second COUNTIF returns 3, so the final result is 7.
This formula works fine, but it is somewhat redundant.
These counts are returned directly to theSUM functionin a singlearray:
And SUM returns 7 as the result.
In other words, COUNTIF returns multiple counts to SUM, and SUM returns a final result.
This is an example ofnestingone formula inside another.
Inside SUMPRODUCT there are two expressions joined by the addition (+)operator.
In the second array, the TRUE values correspond to cells that contain “blue”.
Double-counting risk
When counting with OR logic, be aware of the risk of double-counting.
These values can be numbers, cell references, ranges, arrays, and constants, in any combination.
SUM can handle up to 255 individual arguments.
SUMPRODUCT Function
The Excel SUMPRODUCT function multipliesrangesorarraystogether and returns the sum of products.