COUNTIFS to Exclude Blanks that contain formulas

zero269

Active Member
Joined
Jan 16, 2023
Messages
253
Office Version
  1. 365
Platform
  1. Windows
Hello,

I'm having some trouble with counting cells using two exclusions: "x" or BLANK.

I'm running my test against two tables: One without and one with formulas. The one without formulas produces the correct number (C25), but the one with formulas (G25) is counting the BLANK cells when it shouldn't.

I'm using the following formula for both tests:
Excel Formula:
=COUNTIFS(tblBooks2B[Quiz],"<990000",tblBooks2B[Avail.],"<>"&"x",tblBooks2B[Avail.],"<>"&"")
And I tried droping that empty space "", but that doesn't change the results.
Excel Formula:
=COUNTIFS(tblBooks2B[Quiz],"<990000",tblBooks2B[Avail.],"<>"&"x",tblBooks2B[Avail.],"<>")

Here's what my Sample Data looks like:
Left Table has no formulas (C) and the Right Table is using formulas (G)
VBA Testing.xlsm
ABCDEFG
1QuizTitleAvail.QuizTitleAvail.
29900011-2-3 Peasx9900011-2-3 Peasx
3990003A Best Friend for Woodstock990003A Best Friend for Woodstock 
4990004A Dark, Dark Tale990004A Dark, Dark Tale 
5990005A Gift for Grandpahoopla990005A Gift for Grandpahoopla
681719A Hat for Ivanlac81719A Hat for Ivanlac
7990006A Light in the Atticx990006A Light in the Atticx
8990007A Treasury of Mother Goosehoopla990007A Treasury of Mother Goosehoopla
973447Alabaster's Songlac73447Alabaster's Songlac
10990009All the Worldx990009All the Worldx
11990012Art990012Art 
12990013Bathtime PiggyWiggyhoopla990013Bathtime PiggyWiggyhoopla
13167854Boy and the Oceanlac167854Boy and the Oceanlac
14102089Crippled Lambhoopla102089Crippled Lambhoopla
15990076Halloween Is Here, Corduroy!hoopla990076Halloween Is Here, Corduroy!hoopla
16163599Itsy Bitsy Christmasx163599Itsy Bitsy Christmasx
1752978Just in Case You Ever Wonderlac52978Just in Case You Ever Wonderlac
18109743Oak Inside the Acorn109743Oak Inside the Acorn 
19990008Prince Otto: A Romance990008Prince Otto: A Romance 
20130775Story of a Fierce Bad Rabbitx130775Story of a Fierce Bad Rabbitx
21147312Tale of a Naughty Little Rabbitx147312Tale of a Naughty Little Rabbitx
22182439You Are Mine182439You Are Mine 
23Total2115Total2121
24
25AvailableExclude "x" & EMPTY only5AvailableExclude "x" & EMPTY only7
26Not AvailableCount "x" only3Not AvailableCount "x" only3
27UnknownCount <blank> only2UnknownCount <blank> only2
28Total10Total12
Books
Cell Formulas
RangeFormula
G2:G22G2=IF(ISBLANK(XLOOKUP([@Quiz],tblBooks2A[Quiz],tblBooks2A[Avail.])),"",XLOOKUP([@Quiz],tblBooks2A[Quiz],tblBooks2A[Avail.],""))
B23,F23B23=SUBTOTAL(103,[Title])
C23,G23C23=SUBTOTAL(103,[Avail.])
C25C25=COUNTIFS(tblBooks2A[Quiz],"<990000",tblBooks2A[Avail.],"<>"&"x",tblBooks2A[Avail.],"<>"&"")
C26C26=COUNTIFS(tblBooks2A[Quiz],"<990000",tblBooks2A[Avail.],"x")
C27C27=COUNTIFS(tblBooks2A[Quiz],"<990000",tblBooks2A[Avail.],"")
C28,G28C28=SUM(C25:C27)
G25G25=COUNTIFS(tblBooks2B[Quiz],"<990000",tblBooks2B[Avail.],"<>"&"x",tblBooks2B[Avail.],"<>"&"")
G26G26=COUNTIFS(tblBooks2B[Quiz],"<990000",tblBooks2B[Avail.],"x")
G27G27=COUNTIFS(tblBooks2B[Quiz],"<990000",tblBooks2B[Avail.],"")


Does anyone know how I can do this? I'd like to use this across both table types if possible.
Thank you,
 
Last edited:

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Either of these should work:
Excel Formula:
=COUNTA(FILTER(tblBooks2B[Quiz],(tblBooks2B[Quiz]<990000)*(tblBooks2B[Avail.]<>"x")*(tblBooks2B[Avail.]<>"")))
OR
Excel Formula:
=SUMPRODUCT((tblBooks2B[Quiz]<990000)*(tblBooks2B[Avail.]<>"x")*(tblBooks2B[Avail.]<>""))
 
Upvote 1
Solution
Either of these should work:
Excel Formula:
=COUNTA(FILTER(tblBooks2B[Quiz],(tblBooks2B[Quiz]<990000)*(tblBooks2B[Avail.]<>"x")*(tblBooks2B[Avail.]<>"")))
OR
Excel Formula:
=SUMPRODUCT((tblBooks2B[Quiz]<990000)*(tblBooks2B[Avail.]<>"x")*(tblBooks2B[Avail.]<>""))
Hi Alex,

Thanks again for your expert help.

I tested them both and they absolutely produce the correct values by excluding the cells with "x" and Blanks.
I think I'll use the SUMPRODUCT. I'll need to dissect it later on to see how each portion of the formula works. It's very interesting.
Thank you,

1676870835343.png
 
Upvote 0
Both the filter function and sumproduct are evaluation <>"" differently to the CountIfs, SumIfs functions.
If you can't figure out how they work come back to me.
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,150
Members
453,021
Latest member
Justyna P

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