Using COUNTIF with a range of numbers

Hi, This has been bugging me for a while - and hopefully you can help


I am counting the scores a particular set of children are getting in a test. I need to count how many of these children get between 4.5 and 5.5


I've been trying with the below expression - but it does not work! How do I express between 4.5 and 5.5?


COUNTIFS(Data::$B$3:$B$33,FALSE,Data::I$3:I33,">4.5,<5.5")÷COUNTIF(Data::$B$3:$B $33,FALSE)

MacBook Pro, Mac OS X (10.7.2)

Posted on May 20, 2014 5:25 AM

Reply
10 replies

May 20, 2014 6:39 AM in response to Gwyn Plem

Hi Gwyn,


User uploaded file


Columns C to H are hidden to make a smaller screen shot.

Column B all cells are FALSE (unticked) to keep this simple.


The result appears in the Countifs table with this formula in A2:


=COUNTIFS(Data::B,"=FALSE",Data::I,">4.5",Data::I,"<5.5")


User uploaded file


Note the Header Row in the Data table to allow reference to all Body Cells (for example, Data::B instead of a specific range of cells). That will allow you to add or delete rows, and the COUNTIFS formula will still work


The syntax for COUNTIFS is (from the Functions Panel)


COUNTIFS(test-values, condition, test-values…, condition…)


Regards,

Ian.

May 20, 2014 8:33 AM in response to Gwyn Plem

Hi again Gwyn,


(Sorry for calling you Gwen).


I assume that Column B (TRUE?) is independent of Column I (Score)


I have added some Conditional Highlighting to show Scores that are between 4.5 and 5.5 (I hope I got this right).


User uploaded file


Then added the second part of your formula


User uploaded file


Oops, here is the full formula:


=COUNTIFS(Data::B,"=FALSE",Data::I,">4.5",Data::I,"<5.5")÷COUNTIF(Data::B,"=FALS E")


Two Scores meet >4.5 and <5.5

Divided by 4 FALSE values gives 0.5.


Regards,

Ian.


Message was edited by: Yellowbox. Oops, here is the full formula.

May 20, 2014 10:34 PM in response to Gwyn Plem

Hi Gwyn,


SG is right, you need COUNTIFS.


Also, if the formula is in the last row of the Data table, that row needs to be a Footer Row to prevent the formula refering to its own cell (because it refers to the whole of column I, not a range).


User uploaded file


=COUNTIFS(I,">4.5",I,"<5.5")÷31


Row 1 is a Header (frozen), row 33 is a Footer. Therefore 31 Body Rows.


Regards,

Ian.

May 21, 2014 12:08 AM in response to Yellowbox

Hi Gwyn,


Even better. Use the ROWS function to count the rows in the Data table. Subtract 2 (Header and Footer) to find the number of Body Rows (=number of children in that class). This assumes that every body row contains details for a child.


Formula in the Footer Row

=COUNTIFS(I,">4.5",I,"<5.5")÷(ROWS(I)−2)


Save as Template. Then for a new class, add or delete rows to suit. The formulas will still work without having to modify them.


Regards,

Ian.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Using COUNTIF with a range of numbers

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.