How to count only TRUE values in an array?

Rnkhch

Well-known Member
Joined
Apr 28, 2018
Messages
528
Office Version
  1. 365
Platform
  1. Windows
Hello,

I know how to do this using COUNTIF (or COUNTIFS) which is super easy, but I'm intentionally trying to do it the hard way to improve my Excel array handling skills :biggrin: . I'm trying to use the COUNT function in conjunction with the IF function in the array format to count only the number of TRUE values, in this case the number of cells that have values greater than 10, so I'm trying to write something like this:

{=IF((A1:D1>10),(COUNT(A1:D1)))}

But I can't get it to work, (and I see from the Evaluate Formula dialog that there is no one-to-one correlation between the IF test and the Count, so the COUNT portion of the formula just does its counting to "4" and disregards the IF condition :LOL:).

Thanks for any suggestions!

1576986701813.png
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Using your posted example...

Your formula uses the COUNT(A1:D1) section for every value greater than 10 and resolves to this:
{4,FALSE,4,4}


Also, since the COUNT function counts numeric values and skips text and errors, you'd need an array that returns text or errors for the values you want to skip.

This ARRAY FORMULA does what you want:
=COUNT(1/(A1:D1>10))

However, you can avoid CTRL+SHIFT+ENTER if you use the INDEX in this kind of structure:
=COUNT(INDEX(1/(A1:D1>10),0))

Both formulas return 3.

Does that help?
 
Upvote 0
Another way with a "regular" formula that considers an array of data
=SUMPRODUCTO((A1:D1>10)+0)

Or with an array formula (To accepte press Ctrl+Shift+Enter.):
=SUM(IF(A1:D1>10,1))
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,871
Members
449,054
Latest member
juliecooper255

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