count values between dates

crashbrn34

New Member
Joined
Aug 29, 2019
Messages
7
I have the below spreadsheet for test scores. The first column lists the test dates for each student and another lists the test scores. if the student passed, there's a "P" for their score. The spreadsheet has 260 records with dates throughout the year. I'd like to count how many records with a date between 3/1/19 and 5/15/19 have a "P" listed. (Is it necessary to convert the "P" to a number (e.g., 100) so all values are numerical?)

Test DateStudentScore
7/28/19Sara JP
6/20/19Sara J233
3/15/19Alphie D230
6/28/19Barney CP

<tbody>
</tbody>
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Hi and welcome to MrExcel,

try this:

Book1
ABCDE
1Test DateStudentScore
228-7-2019Sara JP
320-6-2019Sara J233
415-3-2019Alphie D2300
528-6-2019Barney CP
Sheet1
Cell Formulas
RangeFormula
E4=COUNTIFS(C2:C5,"P",A2:A5,">="&DATE(2019,3,1),A2:A5,"<="&DATE(2019,5,15))
 
Last edited:
Upvote 0
Another way is,


Excel 2013/2016
ABCDEF
1TEST DATESTUDENTSCORE
201-Mar-19TestPSTART DATE01-Mar-19
328-Jul-19Sara JPEND DATE15-May-19
420-Jun-19Sara J233P2
515-Mar-19Alphie D230
615-May-19Barney CP
728-Jun-19Test150
Sheet1
Cell Formulas
RangeFormula
F4=COUNTIFS($C$2:$C$10,$E$4,$A$2:$A$10,">="&$F$2,$A$2:$A$10,"<="&$F$3)
 
Upvote 0
That worked. I also used a formula where I listed the start and end dates for the period i wanted to count and referenced those--that way of calculating worked as well....=COUNTIFS(A2:A5, ">="&W10, A2:A5,"<="&X10, C2:C5, "P"), where X and W were the start and end dates.

But now I have another issue. I want to count how many times "P" is listed across multiple columns (I added scores for other tests in columns C & D). When I tried to update the formula to count "P" across the 3 columns (changing the above to C2: D5), it returned a #VALUE error.

Hi and welcome to MrExcel,

try this:
ABCDE
1Test DateStudentScore
228-7-2019Sara JP
320-6-2019Sara J233
415-3-2019Alphie D2300
528-6-2019Barney CP

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
E4=COUNTIFS(C2:C5,"P",A2:A5,">="&DATE(2019,3,1),A2:A5,"<="&DATE(2019,5,15))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
yes this is what i used... but now another issue is that i want to expand the formula to count P in scores i added to columns C and D. When I modify the range from C2:D5, I get a #VALUE error
 
Upvote 0
yes this is what i used... but now another issue is that i want to expand the formula to count P in scores i added to columns C and D. When I modify the range from C2:D5, I get a
#VALUE
error

Another way is,

Excel 2013/2016
ABCDEF
1TEST DATESTUDENTSCORE
201-Mar-19TestPSTART DATE01-Mar-19
328-Jul-19Sara JPEND DATE15-May-19
420-Jun-19Sara J233P2
515-Mar-19Alphie D230
615-May-19Barney CP
728-Jun-19Test150

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
F4=COUNTIFS($C$2:$C$10,$E$4,$A$2:$A$10,">="&$F$2,$A$2:$A$10,"<="&$F$3)

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
yes this is what i used... but now another issue is that i want to expand the formula to count P in scores i added to columns C and D. When I modify the range from C2:D5, I get a
#VALUE
error


I guess if you can try this.

Code:
=SUMPRODUCT(($C$2:$D$7=$E$4)*(($A$2:$A$7>=$F$2)*($A$2:A7<=$F$3)))
 
Upvote 0
What if I want to convert the COUNTIFS formula that calculates P for one test during a time period into an average % for the number of tests with a P during the date ranges? (see below)


Column AColumn BColumn CColumn DColumn EColumn fColumn G
DateStudentMathEnglishHistoryStart measurement periodEnd measurement period
3/1/19AVP2204/1/196/30/19
3/28/19AV2327/1/199/30/19
4/25/19JessP21510/1/1912/31/19
5/5/19SaraPP
7/28/19John210233

<tbody style="border-collapse: collapse; width: auto;">
</tbody>
 
Upvote 0
Do you need something like this?


You just have to adjust the formula of @Sam_D_Ben in post #4


<table border="1" cellspacing="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:127.37px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:76.04px;" /><col style="width:172.04px;" /><col style="width:172.04px;" /><col style="width:76.04px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td><td >H</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Date</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Student</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Math</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">English</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">History</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">Start measurement period</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">End measurement period</td><td style="background-color:#ffff00; font-weight:bold; text-align:center; ">P</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:right; ">01/mar/2019</td><td >AV</td><td >P</td><td > </td><td style="text-align:right; ">220</td><td style="background-color:#c2d69a; text-align:right; ">01/abr/2019</td><td style="background-color:#c2d69a; text-align:right; ">30/jun/2019</td><td style="background-color:#c2d69a; text-align:right; ">1</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">28/mar/2019</td><td >AV</td><td > </td><td style="text-align:right; ">232</td><td > </td><td style="background-color:#93cddd; text-align:right; ">01/jul/2019</td><td style="background-color:#93cddd; text-align:right; ">30/sep/2019</td><td style="background-color:#93cddd; text-align:right; ">4</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td style="text-align:right; ">25/abr/2019</td><td >Jess</td><td style="background-color:#c2d69a; "> </td><td style="background-color:#c2d69a; ">P</td><td style="background-color:#c2d69a; text-align:right; ">215</td><td style="background-color:#ffc000; text-align:right; ">01/oct/2019</td><td style="background-color:#ffc000; text-align:right; ">31/dic/2019</td><td style="background-color:#ffc000; text-align:right; ">2</td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >5</td><td style="text-align:right; ">30/ago/2019</td><td >Sara</td><td style="background-color:#93cddd; ">P</td><td style="background-color:#93cddd; ">P</td><td style="background-color:#93cddd; "> </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >6</td><td style="text-align:right; ">28/jul/2019</td><td >John</td><td style="background-color:#93cddd; text-align:right; ">210</td><td style="background-color:#93cddd; text-align:right; ">233</td><td style="background-color:#93cddd; "> </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >7</td><td style="text-align:right; ">28/ago/2019</td><td >Sara</td><td style="background-color:#93cddd; "> </td><td style="background-color:#93cddd; "> </td><td style="background-color:#93cddd; ">P</td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >8</td><td style="text-align:right; ">28/sep/2019</td><td >Dam</td><td style="background-color:#93cddd; ">P</td><td style="background-color:#93cddd; "> </td><td style="background-color:#93cddd; "> </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >9</td><td style="text-align:right; ">28/oct/2019</td><td >Sue</td><td style="background-color:#ffc000; "> </td><td style="background-color:#ffc000; "> </td><td style="background-color:#ffc000; "> </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >10</td><td style="text-align:right; ">28/nov/2019</td><td >James</td><td style="background-color:#ffc000; "> </td><td style="background-color:#ffc000; ">P</td><td style="background-color:#ffc000; "> </td><td > </td><td > </td><td > </td></tr><tr style="height:19px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >11</td><td style="text-align:right; ">28/dic/2019</td><td >Rob</td><td style="background-color:#ffc000; "> </td><td style="background-color:#ffc000; "> </td><td style="background-color:#ffc000; ">P</td><td > </td><td > </td><td > </td></tr></table><br /><table style="font-family:Arial; font-size:10pt; border-style: groove ;border-color:#00ff00;background-color:#fffcf9; color:#000000; "><tr><td ><b></b></td></tr><tr><td ><table border = "1" cellspacing="0" cellpadding="2" style="font-family:Arial; font-size:9pt;"><tr style="background-color:#cacaca; font-size:10pt;"><td >Cell</td><td >Formula</td></tr><tr><td >H2</td><td >=SUMPRODUCT(($A$2:$A$11>=F2)*($A$2:$A$11<=G2)*($C$2:$E$11="P"))</td></tr></table></td></tr></table>
 
Upvote 0
Do you need something like this?


You just have to adjust the formula of @Sam_D_Ben in post #4


Hi DanteAmor, Thanks a lot for pointing it. I was stuck with that part.

The OP wants the average count of "P" in % with in the given period.

I guess so.


Excel 2013/2016
HIJKLMNOP
1DATESTUDENTMATHENGLISHHISTORYSTART MEASUREMENT PERIODEND MEASUREMENT PERIODSELECT SUBJECTAVG%
23/1/2019AVP2204/1/20196/30/2019MATH33%
33/28/2019AV2327/1/20199/30/2019COUNT P
44/25/2019JessP21510/1/201912/31/2019P
55/5/2019SaraPP
67/28/2019John210233
31Aug18
Cell Formulas
RangeFormula
P2=SUMPRODUCT(($J$1:$L$1=$O$2)*($H$2:$H$6>=$M$2)*($H$2:$H$6<=$N$2)*($J$2:$L$6=$O$4))/SUMPRODUCT(($H$2:$H$6>=$M$2)*($H$2:$H$6<=$N$2)*($J$2:$L$6=$O$4))
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

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