How to count the number of numbers in a given period?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,687
Office Version
  1. 365
Platform
  1. Windows
I have a spreadsheet for recording various medical metrics requested by my doctor (blood pressure, weight, etc). I have expressions for calculating the max (using MaxIfs), min (using MinIfs), and average (using AverageIfs) of a period of time. But I am having trouble coming up an expression for the number of readings. I tried to use CountIfs, but could not come up with an expression for the criteria. I also tried SumProduct as in the mini-sheet below, but that is also not working.

I would appreciate any help.

Book1
BCD
4
5DateSystolic
68/20/24102
78/27/24
88/30/2497
99/15/24113
109/22/24
119/30/24114
1210/05/24
1310/15/24
1410/20/2498
15Number of days30
16First day09/20/24
17Number of readings0
18Maximum114
19Average106
20Minimum98
Sheet1
Cell Formulas
RangeFormula
C16C16=TODAY()-NumDays
D17D17=SUMPRODUCT((Table1[Date]>=(TODAY()-NumDays)), ISNUMBER(Table1[Systolic]))
D18D18=MAXIFS(Table1[Systolic],Table1[Date],">=" & FirstDay)
D19D19=AVERAGEIFS(Table1[Systolic],Table1[Date],">=" & FirstDay)
D20D20=MINIFS(Table1[Systolic],Table1[Date],">=" & FirstDay)
Named Ranges
NameRefers ToCells
FirstDay=Sheet1!$C$16D18:D20
NumDays=Sheet1!$C$15D17, C16
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
You can use the below for Countifs :
Excel Formula:
=COUNTIFS(Table1[Date],">"&B13,Table1[Systolic],"<>"&"")
 
Upvote 0
You can use the below for Countifs :
Excel Formula:
=COUNTIFS(Table1[Date],">"&B13,Table1[Systolic],"<>"&"")
That almost works. The problem is that it counts all non-blank cells. That includes cells with letters or blanks.

Book1
BCD
5DateSystolic
68/20/24102
78/27/24
88/30/2497
99/15/24113
109/22/24
119/30/24114
1210/05/24b
1310/15/24
1410/20/2498
15
16
17Number of days52
18First day08/30/24
19Number of readings4
20Number of readings6
21Maximum114
22Average106
23Minimum97
Sheet1
Cell Formulas
RangeFormula
C18C18=TODAY()-NumDays
D19D19=SUMPRODUCT(--(Table1[Date]>=FirstDay), ISNUMBER(Table1[Systolic])*1)
D20D20=COUNTIFS(Table1[Date],">="&FirstDay,Table1[Systolic],"<>"&"")
D21D21=MAXIFS(Table1[Systolic],Table1[Date],">=" & FirstDay)
D22D22=AVERAGEIFS(Table1[Systolic],Table1[Date],">=" & FirstDay)
D23D23=MINIFS(Table1[Systolic],Table1[Date],">=" & FirstDay)
Named Ranges
NameRefers ToCells
FirstDay=Sheet1!$C$18D19:D23
NumDays=Sheet1!$C$17C18
 
Upvote 0
Hi, assuming it can never be zero or less than zero, you could also try:
Excel Formula:
=COUNTIFS(Table1[Date],">="&FirstDay,Table1[Systolic],">0")
 
Upvote 0
Solution
Are you perhaps over thinking this,
Me? Naw? Never. At least I don't think so. Wait! Let me think about that...... I'll get back to you on that.

that is exactly what =COUNT does
I didn't think count would work because I only want to count the numbers in the last N days.

If you really have to use COUNTIFS then this seems to work fine:
Excel Formula:
=COUNTIFS(Table1[Systolic],"<300")
Huh? Where did the 300 come from?
 
Upvote 0
Oops my bad I didn't pick up on the date criteria.
I figured blood pressure wouldn't go over 300 but any number seems to force it to only pick up numbers.
I thought when I tried >0 it didn't work but that was my mistake and that works as well.
 
Upvote 0
Hi, assuming it can never be zero or less than zero, you could also try:
Excel Formula:
=COUNTIFS(Table1[Date],">="&FirstDay,Table1[Systolic],">0")
Yes! That's what I was looking for. My data can never be zero or negative, so that works.

I was looking for a way to use IsNumber(). If my data could be any number, is there an expression that will work for that?
 
Upvote 0

Forum statistics

Threads
1,223,884
Messages
6,175,175
Members
452,615
Latest member
bogeys2birdies

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