Counting Consecutive Days based on Criteria

zcavaricci

New Member
Joined
Apr 24, 2017
Messages
10
Hello,

I need to count the number occurences where blood sugar was >180 2x in a Day for =>3 consecutive days by patient. I have one table with the following structure:

Date/TimePatient IDGlucose Reading
1/28/2017 17:36A192
1/28/2017 20:12A311
1/29/2017 9:58A214
1/29/2017 10:58A181
1/30/2017 20:45A279
1/30/2017 21:45A181
1/31/2017 7:48A157
1/31/2017 12:33A157
1/31/2017 17:48A167
1/28/2017 12:35B158
1/29/2017 12:09B190
1/29/2017 17:05B211
1/30/2017 7:41B197
1/30/2017 12:05B211
1/30/2017 17:31B231
1/31/2017 21:26B188
1/5/2017 22:05C205
1/5/2017 23:40C216
1/6/2017 3:18C195
1/6/2017 7:54C187
1/7/2017 12:54C210
1/7/2017 17:22C379
1/9/2017 7:37C191

<colgroup><col><col><col></colgroup><tbody>
</tbody>


Results Expected:
Patient# Occurrences
A1
C1

<tbody>
</tbody>
 
What should be done if patient only has one results on a day? Example, patient B on 1/31 in post #1
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
If I do 1 patient with the data I supplied here I get the correct answer, when I apply it to my spreadsheet with 25833 rows of data (1281 patients), I don't get the correct answer? Is there a specific sort that I should apply (Sort by Date/Time, Patient or Patient, Date/Time)?

Appreciate all the help here!

Below is the data as supplied to me without any sorting (by Date/Time).

Date and TimePatient IDGlu>180 2x in a day
1/1/2017 0:08C98FALSE
1/1/2017 0:56A102FALSE
1/1/2017 3:56A159FALSE
1/1/2017 6:13C108FALSE
1/1/2017 7:58A139FALSE
1/1/2017 11:29A171FALSE
1/1/2017 11:41C424FALSE
1/1/2017 16:14A172FALSE
1/1/2017 16:41C153FALSE
1/1/2017 20:57A152FALSE
1/1/2017 21:23C106FALSE
1/2/2017 0:10A122FALSE
1/2/2017 4:25A160FALSE
1/2/2017 7:27C39TRUE
1/2/2017 7:39A140FALSE
1/2/2017 7:48C50TRUE
1/2/2017 8:19C123TRUE
1/2/2017 10:25C282TRUEC1
1/2/2017 11:30A156FALSE
1/2/2017 11:40C308TRUEC1
1/2/2017 15:50A142FALSE
1/2/2017 16:51C421TRUEC1
1/2/2017 20:16C237TRUEC1
1/2/2017 20:35A150FALSE
1/2/2017 21:36C187TRUEC1
1/3/2017 0:31A124FALSE
1/3/2017 4:11A162FALSE
1/3/2017 7:49C294TRUEC1
1/3/2017 8:27A146FALSE
1/3/2017 11:45A145FALSE
1/3/2017 11:52C253TRUEC1
1/3/2017 15:37A140FALSE
1/3/2017 17:16C228TRUEC1
1/3/2017 20:49A143FALSE
1/3/2017 20:55C131TRUE
1/4/2017 0:27A136FALSE
1/4/2017 4:16A177FALSE
1/4/2017 7:42C394TRUEC1
1/4/2017 9:32A149FALSE
1/4/2017 11:59C439TRUEC1
1/4/2017 12:20A177FALSE
1/4/2017 13:07C481TRUEC1
1/4/2017 14:50C263TRUEC1
1/4/2017 16:08A138FALSE
1/4/2017 17:10C198TRUEC1
1/4/2017 19:57A163FALSE
1/4/2017 21:32C172TRUE
1/4/2017 23:47A128FALSE
1/5/2017 3:35A189FALSE
1/5/2017 7:08C80TRUE
1/5/2017 8:28A144FALSE
1/5/2017 9:27C359TRUEC1
1/5/2017 11:19A151FALSE
1/5/2017 11:38C368TRUEC1
1/5/2017 16:22A141FALSE
1/5/2017 17:20C158TRUE
1/5/2017 20:03A141FALSE
1/5/2017 21:50C48TRUE
1/5/2017 21:53C56TRUE
1/5/2017 22:19C65TRUE
1/5/2017 22:41C91TRUE
1/5/2017 23:13A146FALSE
1/5/2017 23:30C190TRUEC1
1/6/2017 4:16A163FALSE
1/6/2017 7:03C319TRUE
1/6/2017 9:23A162FALSE
1/6/2017 11:09A156FALSE
1/6/2017 12:01C279TRUE
1/6/2017 16:21A130FALSE
1/6/2017 17:28C70TRUE
1/6/2017 20:46A182FALSE
1/6/2017 21:31C58TRUE
1/6/2017 21:53C82TRUE
1/7/2017 0:18A127FALSE
1/7/2017 0:21C205TRUE
1/7/2017 4:16A181FALSE
1/7/2017 7:46A123FALSE
1/7/2017 8:01C74TRUE
1/7/2017 11:56C346TRUE
1/7/2017 12:30A163FALSE
1/7/2017 13:31C328TRUE
1/7/2017 16:17A152FALSE
1/7/2017 16:58C131TRUE
1/7/2017 21:17A105FALSE
1/7/2017 21:20C198TRUE
1/8/2017 0:43A158FALSE
1/8/2017 3:55A147FALSE
1/8/2017 7:38A143FALSE
1/8/2017 7:45C65TRUE
1/8/2017 11:23A154FALSE
1/8/2017 11:48C228TRUE
1/8/2017 16:13A154FALSE
1/8/2017 17:14C244TRUE
1/8/2017 19:22A134FALSE
1/8/2017 21:07C82TRUE
1/9/2017 0:31C158FALSE
1/9/2017 0:55A159FALSE
1/9/2017 3:50A155FALSE
1/9/2017 7:37C91FALSE
1/9/2017 8:16A197FALSE
1/9/2017 12:07C167FALSE
1/9/2017 13:06A148FALSE
1/9/2017 16:16A143FALSE
1/9/2017 16:46C85FALSE
1/9/2017 20:18A149FALSE
1/9/2017 20:19C99FALSE
1/10/2017 0:05A144FALSE
1/10/2017 4:19A144FALSE
1/10/2017 7:30C93FALSE
1/10/2017 8:26A169FALSE
1/10/2017 11:28A172FALSE
1/10/2017 11:57C89FALSE
1/10/2017 15:27A135FALSE
1/10/2017 16:47C50FALSE
1/10/2017 17:35C109FALSE
1/10/2017 19:33A156FALSE
1/10/2017 20:56C107FALSE
1/10/2017 23:57A153FALSE
1/11/2017 3:55A173FALSE
1/11/2017 7:45C116FALSE
1/11/2017 7:59A176FALSE
1/11/2017 11:27A161FALSE
1/11/2017 11:56C131FALSE
1/11/2017 16:06A143FALSE
1/11/2017 16:54C62FALSE
1/11/2017 18:12C302FALSE
1/11/2017 19:48A136FALSE
1/11/2017 21:09C171FALSE
1/11/2017 23:57A161FALSE
1/12/2017 3:32A133TRUE
1/12/2017 7:44A191TRUE
1/12/2017 7:50C47TRUE
1/12/2017 7:51C41TRUE
1/12/2017 8:12C69TRUE
1/12/2017 8:49C253TRUE
1/12/2017 11:15A153TRUE
1/12/2017 12:06C265TRUE
1/12/2017 16:17A181TRUE
1/12/2017 16:57C88TRUE
1/12/2017 19:35A135TRUE
1/12/2017 21:26C103TRUE
1/12/2017 23:57A153TRUE
1/13/2017 3:31A147FALSE
1/13/2017 7:45A175FALSE
1/13/2017 7:48C164FALSE
1/13/2017 11:20A147FALSE
1/13/2017 12:32C174FALSE
1/13/2017 15:48A151FALSE
1/13/2017 17:03C128FALSE
1/13/2017 20:06A167FALSE
1/13/2017 21:08C155FALSE
1/13/2017 23:41A172FALSE
1/14/2017 4:33A185FALSE
1/14/2017 7:42C140FALSE
1/14/2017 8:29A175FALSE
1/14/2017 11:42C226FALSE
1/14/2017 11:45A146FALSE
1/14/2017 16:16A152FALSE
1/14/2017 16:57C103FALSE
1/14/2017 21:00A164FALSE
1/14/2017 21:21C107FALSE
1/15/2017 0:26A149TRUE
1/15/2017 4:12A134TRUE
1/15/2017 7:50C142FALSE
1/15/2017 8:05A183TRUE
1/15/2017 11:54C242FALSE
1/15/2017 12:04A162TRUE
1/15/2017 16:35C147FALSE
1/15/2017 16:58A163TRUE
1/15/2017 20:30C151FALSE
1/15/2017 20:44A181TRUE
1/16/2017 0:29A136TRUE
1/16/2017 4:14A189TRUE
1/16/2017 7:46A172TRUE
1/16/2017 7:46C59FALSE
1/16/2017 7:58C59FALSE
1/16/2017 8:16C77FALSE
1/16/2017 11:47A165TRUE
1/16/2017 11:51C213FALSE
1/16/2017 15:27A182TRUE
1/16/2017 17:02C63FALSE
1/16/2017 17:51C164FALSE
1/16/2017 19:47A167TRUE
1/16/2017 20:54C61FALSE
1/16/2017 21:37C105FALSE
1/16/2017 23:57A158TRUE
1/17/2017 4:34A161FALSE
1/17/2017 7:52C101FALSE
1/17/2017 8:30A171FALSE
1/17/2017 11:31C209FALSE
1/17/2017 11:39A181FALSE
1/17/2017 16:31A171FALSE
1/17/2017 17:02C96FALSE
1/17/2017 20:13A179FALSE
1/17/2017 20:59C88FALSE
1/18/2017 0:15A167FALSE
1/18/2017 4:18A177FALSE
1/18/2017 7:36C186FALSE
1/18/2017 8:45A176FALSE
1/18/2017 11:18A172FALSE
1/18/2017 12:06C103FALSE
1/18/2017 16:00A185FALSE
1/18/2017 20:20A164FALSE
1/19/2017 0:18A162FALSE
1/19/2017 3:43A157FALSE
1/19/2017 8:55A178FALSE
1/19/2017 11:24A183FALSE
1/19/2017 16:10A132FALSE
1/19/2017 20:22A174FALSE
1/19/2017 23:49A136FALSE
1/20/2017 4:00A158FALSE
1/20/2017 8:51A153FALSE
1/20/2017 14:11A168FALSE
1/23/2017 13:02A180FALSE
1/24/2017 6:23A205TRUEA1
1/24/2017 15:24A199TRUEA1
1/24/2017 21:02A197TRUEA1
1/25/2017 5:42A218TRUEA1
1/25/2017 18:03A265TRUEA1
1/25/2017 21:39A208TRUEA1
1/26/2017 6:02A246TRUEA1
1/26/2017 10:11A215TRUEA1
1/26/2017 14:33A238TRUEA1
1/26/2017 21:20A192TRUEA1
1/27/2017 5:54A236TRUEA1
1/27/2017 9:51A215TRUEA1
1/27/2017 13:21A264TRUEA1
1/27/2017 21:46A255TRUEA1
1/28/2017 5:28A252TRUEA1
1/28/2017 10:09A226TRUEA1
1/28/2017 13:33A240TRUEA1
1/28/2017 21:57A230TRUEA1
1/29/2017 4:59A203TRUEA1
1/29/2017 13:00A224TRUEA1
1/29/2017 22:11A201TRUEA1
1/30/2017 6:21A201FALSE<--{=SUM((B237=$B$2:$B$237)*(INT(A237)=INT($A$2:$A$237))*($C$2:$C$237>180))>=2}
Patient #Occurences
A3<-----Should be 1<--{=SUM(IF(FREQUENCY(IF(($D$2:$D$237=TRUE)*($B$2:$B$237=A240),ROW($D$2:$D$237)),IF(($D$2:$D$237<>TRUE)*($B$2:$B$237=A240),ROW($D$2:$D$237)))>=6,1,0))}
C2<-----Should be 1

<tbody>
</tbody><colgroup><col><col><col><col><col></colgroup>
 
Upvote 0

Forum statistics

Threads
1,221,699
Messages
6,161,367
Members
451,700
Latest member
Eccymarge

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