Use of COUNTIFS vs SUMIFS with Array Formula

John_F

New Member
Joined
Dec 17, 2014
Messages
44
I'm having trouble getting COUNTIFS to work with an array formula. I can get both the SUMIF and COUNTIF to work with a single criterion but when I add another criterion I can still get the SUMIFS to work but the COUNTIFS returns an error.



Excel 2010
ABCDEFGHIJ
1PRODUCTDATEQTYUNIT PRICEAMOUNTPRODUCTSQTY
2PRODUCT A01/19/144904,9572,428,930PRODUCT A4618=SUMPRODUCT(--COUNTIF(G2:G3,A2:A31),C2:C31)
3PRODUCT A03/27/142922,299671,308PRODUCT B4618=SUMPRODUCT(--SUMIF(A2:A31,G2:G3,C2:C31))
4PRODUCT E07/03/142192,234489,246
5PRODUCT E04/05/14363,928141,408DATE
6PRODUCT E03/29/144414,9472,181,6276/30/2014#VALUE!=SUMPRODUCT(--COUNTIFS(G2:G3,A2:A31,B2:B31,">"&G6),C2:C31)
7PRODUCT C07/13/143973,1591,254,123589=SUMPRODUCT(--SUMIFS(C2:C31,A2:A31,G2:G3,B2:B31,">"&G6))
8PRODUCT D12/18/143503,5711,249,850
9PRODUCT E07/10/144531,235559,455
10PRODUCT E05/19/14463,544163,024
11PRODUCT B01/16/144654,6642,168,760
12PRODUCT B03/27/144363,2541,418,744
13PRODUCT C01/06/143664,2811,566,846
14PRODUCT D05/11/141842,274418,416
15PRODUCT A03/22/144473,7051,656,135
16PRODUCT D03/27/1471,0967,672
17PRODUCT E04/13/144971,443717,171
18PRODUCT A05/04/144704,8072,259,290
19PRODUCT B02/21/142092,375496,375
20PRODUCT A03/19/14991,070105,930
21PRODUCT E10/25/144573,3141,514,498
22PRODUCT B12/28/142912,553742,923
23PRODUCT C04/05/144392,4131,059,307
24PRODUCT B12/30/141392,234310,526
25PRODUCT B01/23/143952,6241,036,480
26PRODUCT A02/26/142494,7091,172,541
27PRODUCT E09/09/144651,282596,130
28PRODUCT A01/23/144774,2402,022,480
29PRODUCT E12/21/142483,586889,328
30PRODUCT B12/18/141592,102334,218
31PRODUCT C11/17/143833,8541,476,082
COUNTIF vs SUMIF
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
In this version

=SUMPRODUCT(--COUNTIFS(G2:G3,A2:A31,B2:B31,">"&G6),C2:C31)

The COUNTIFS is invalid - the ranges marked in red need to be the same size in COUNTIFS, otherwise you get #VALUE! error

The COUNTIFS itself will work with the first two ranges swapped, i.e.

=COUNTIFS(A2:A31,G2:G3,B2:B31,">"&G6)

....but that returns a 2 element array so you can't use it in SUMPRODUCT with C2:C31

Your SUMIFS version works fine for your purposes, doesn't it? Why do you need this one, or is it for learning purposes?

You can make it work if you put the new criteria in as part of SUMPRODUCT rather than the COUNTIFS, like this:

=SUMPRODUCT(COUNTIF(G2:G3,A2:A31),--(B2:B31>G6),C2:C31)

BTW you don't require the -- in any of your formulas because the COUNTIFS/SUMIFS functions are returning numbers anyway
 
Last edited:
Upvote 0
Thanks. I'm just trying to further understand the use of COUNTIFS in array formulas. Upon further review, I see that the SUMIFS version is returning a 2 element array but doesn't have to deal with C2:C31, so it works.
I didn't realize that COUNTIFS/SUMIFS would return numbers without some math operation but now that I think about it more, it makes sense that it does (return numbers). Thanks again for the help, you helped me out with another COUNTIFS question several weeks ago.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top